From 5ed68715f3ba01dd875a0322b6636cbbfb094897 Mon Sep 17 00:00:00 2001 From: Made Baruna Date: Fri, 16 Apr 2021 21:20:07 +0700 Subject: [PATCH] Fix the timeline time on the detail modal - fix #34 --- src/data/timeline.js | 2 +- src/routes/timeline/_detail.svelte | 5 +++-- src/routes/timeline/index.svelte | 27 ++++++++++++++------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/data/timeline.js b/src/data/timeline.js index 7898b522..a716ac37 100644 --- a/src/data/timeline.js +++ b/src/data/timeline.js @@ -54,7 +54,7 @@ export const eventsData = [ end: '2021-04-23 04:00:00', color: '#93E05A', zoom: '170%', - url: 'https://genshin.mihoyo.com/en/news/detail/9741', + url: 'https://www.hoyolab.com/genshin/article/295568', showOnHome: true, }, ], diff --git a/src/routes/timeline/_detail.svelte b/src/routes/timeline/_detail.svelte index 1e9a76bf..5983f14e 100644 --- a/src/routes/timeline/_detail.svelte +++ b/src/routes/timeline/_detail.svelte @@ -5,12 +5,13 @@ import { onMount } from 'svelte'; export let event; + export let timeDifference; - let now = dayjs(); + let now = dayjs().add(timeDifference, 'minute'); onMount(() => { const interval = setInterval(() => { - now = dayjs(); + now = dayjs().add(timeDifference, 'minute'); }, 1000); return () => { diff --git a/src/routes/timeline/index.svelte b/src/routes/timeline/index.svelte index d1e5b4a3..941f6c71 100644 --- a/src/routes/timeline/index.svelte +++ b/src/routes/timeline/index.svelte @@ -15,19 +15,6 @@ const { open: openModal } = getContext('simple-modal'); - function openDetail(event) { - openModal( - DetailModal, - { - event, - }, - { - closeButton: false, - styleWindow: { background: '#25294A', width: '600px' }, - }, - ); - } - let loading = true; let timelineContainer; @@ -50,6 +37,20 @@ let events = []; let today = dayjs(); + function openDetail(event) { + openModal( + DetailModal, + { + event, + timeDifference, + }, + { + closeButton: false, + styleWindow: { background: '#25294A', width: '600px' }, + }, + ); + } + function convertToDate(e, i) { const start = dayjs(e.start, 'YYYY-MM-DD HH:mm:ss').subtract(timeDifferenceEvent, 'minute'); const end = dayjs(e.end, 'YYYY-MM-DD HH:mm:ss').subtract(timeDifferenceEvent, 'minute');