From 880b27f655e41d03315817edf451f2dc6beb5028 Mon Sep 17 00:00:00 2001 From: Julian Freeman Date: Sun, 22 Mar 2026 23:45:08 -0400 Subject: [PATCH] add now time --- src/App.vue | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/App.vue b/src/App.vue index b1cd667..7b809f9 100644 --- a/src/App.vue +++ b/src/App.vue @@ -55,6 +55,18 @@ const editingEvent = ref({ id: 0, date: "", start_minute: 0, end_minute const hoveredTime = ref(null); const hoveredEventDetails = ref<{ event: DBEvent; x: number; y: number } | null>(null); +const currentLogicalMinute = ref(-1); +let currentMinuteInterval: number | null = null; +const updateCurrentMinute = () => { + const now = new Date(); + if (now.toLocaleDateString('sv') === currentDate.value) { + const m = now.getHours() * 60 + now.getMinutes(); + currentLogicalMinute.value = (m < TIME_OFFSET_MINUTES ? m + 1440 : m) - TIME_OFFSET_MINUTES; + } else { + currentLogicalMinute.value = -1; + } +}; + const handleEventMouseEnter = (ev: DBEvent, e: MouseEvent) => { hoveredEventDetails.value = { event: ev, x: e.clientX, y: e.clientY }; }; @@ -150,12 +162,19 @@ const calendarDays = computed(() => { const selectCalendarDate = (date: Date) => { currentDate.value = date.toLocaleDateString('sv'); // sv locale gives YYYY-MM-DD isCalendarOpen.value = false; + selectedImage.value = null; + lockedImage.value = null; + previewSrc.value = ""; + hoveredTime.value = null; + updateCurrentMinute(); loadTimeline(true); loadEvents(); }; // --- Logic --- onMounted(async () => { window.addEventListener('mousedown', handleClickOutside); + updateCurrentMinute(); + currentMinuteInterval = window.setInterval(updateCurrentMinute, 60000); store = await load("config.json"); const path = await store.get("savePath"); const dPath = await store.get("dbPath"); @@ -177,6 +196,7 @@ onMounted(async () => { onUnmounted(() => { window.removeEventListener('mousedown', handleClickOutside); + if (currentMinuteInterval) window.clearInterval(currentMinuteInterval); if (captureUnlisten) captureUnlisten(); }); @@ -539,6 +559,7 @@ const handleExport = async () => {
{{ hoveredTime }}
+
{{ logicalMinutesToTime(currentLogicalMinute) }}