From 41937fbe7c091665fd353fee63105407bd76da34 Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Wed, 10 Jan 2024 12:26:37 -0800
Subject: fix(schedule): bypass forced refresh on move

---
 src/lib/Tools/Schedule/CoverBypass.svelte | 63 +++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 src/lib/Tools/Schedule/CoverBypass.svelte

(limited to 'src/lib/Tools/Schedule/CoverBypass.svelte')

diff --git a/src/lib/Tools/Schedule/CoverBypass.svelte b/src/lib/Tools/Schedule/CoverBypass.svelte
new file mode 100644
index 00000000..0467c68e
--- /dev/null
+++ b/src/lib/Tools/Schedule/CoverBypass.svelte
@@ -0,0 +1,63 @@
+<script lang="ts" ts>
+	import type { Media } from '$lib/AniList/media';
+	import MediaTitleDisplay from '$lib/List/MediaTitleDisplay.svelte';
+	import type { SubsPleaseEpisode } from '$lib/Media/Anime/Airing/Subtitled/subsPlease';
+	import HoverCover from '$lib/Media/Cover/HoverCover.svelte';
+	import {
+		onMouseEnter,
+		type HoverCoverResponse,
+		onMouseLeave,
+		onMouseMove
+	} from '$lib/Media/Cover/hoverCover';
+
+	import { outboundLink } from '$lib/Media/links';
+	import settings from '$stores/settings';
+
+	export let media: Media | null;
+	export let entry: SubsPleaseEpisode;
+
+	let hoverCoverState: HoverCoverResponse = {};
+
+	const titleSelect = (media: Media | null) =>
+		media ? media.title.english || media.title.romaji || media.title.native : null;
+</script>
+
+<a
+	href={media
+		? outboundLink(media, 'anime', $settings.displayOutboundLinksTo)
+		: outboundLink(
+				null,
+				'anime',
+				$settings.displayOutboundLinksTo,
+				true,
+				titleSelect(media) || entry.title
+		  )}
+	target="_blank"
+	on:mouseenter={() => {
+		const response = onMouseEnter(media, entry);
+
+		hoverCoverState.hovering = response.hovering;
+		hoverCoverState.item = response.item;
+		hoverCoverState.media = response.media;
+	}}
+	on:mouseleave={() => {
+		const response = onMouseLeave();
+
+		hoverCoverState.hovering = response.hovering;
+		hoverCoverState.item = response.item;
+		hoverCoverState.media = response.media;
+	}}
+	on:mousemove={(e) => {
+		const response = onMouseMove(e, 300);
+
+		hoverCoverState.style = response.style;
+	}}
+>
+	{#if media}
+		<MediaTitleDisplay title={media.title} />
+	{:else}
+		{entry.title}
+	{/if}
+</a>
+
+<HoverCover options={hoverCoverState} width={300} />
-- 
cgit v1.2.3

