diff --git a/src/lib/components/MemoryCard.svelte b/src/lib/components/MemoryCard.svelte
index dc548a0..51a920d 100644
--- a/src/lib/components/MemoryCard.svelte
+++ b/src/lib/components/MemoryCard.svelte
@@ -1,70 +1,78 @@
-
-
-
-
- {#if !image}
-
-
-
- {/if}
-
-
-
{destination}
-
{startDate} - {endDate}
-
+
+
+
+ {#if !image}
+
+
+
+ {/if}
+
+
+
{destination}
+
{startDate} - {endDate}
+
\ No newline at end of file
diff --git a/src/lib/components/NewMemoryPopup.svelte b/src/lib/components/NewMemoryPopup.svelte
index 2f7b52c..3661745 100644
--- a/src/lib/components/NewMemoryPopup.svelte
+++ b/src/lib/components/NewMemoryPopup.svelte
@@ -233,6 +233,8 @@
}
let isUploading = false;
+
+ const isDark = document.documentElement.classList.contains('dark');
{#if showPopup}
diff --git a/src/lib/components/WorldMap.svelte b/src/lib/components/WorldMap.svelte
index 34034cb..f81f911 100644
--- a/src/lib/components/WorldMap.svelte
+++ b/src/lib/components/WorldMap.svelte
@@ -7,6 +7,7 @@
import { ref, get } from 'firebase/database';
import { db } from '../../firebase';
import { goto } from '$app/navigation';
+ import NewMemoryPopup from '$lib/components/NewMemoryPopup.svelte';
let mapContainer: HTMLDivElement;
@@ -65,6 +66,8 @@
}
let cleanup: (() => void) | undefined;
+ let showNewMemoryPopup = false;
+ let selectedTripIdForMemory = '';
onMount(() => {
let mounted = true;
@@ -176,8 +179,32 @@
.attr('class', 'trip-marker')
.attr('data-has-memory', trip.hasMemory ? 'true' : 'false')
.style('cursor', 'pointer')
- .on('click', function () {
- goto(`/itinerary/${trip.tid}`);
+ .on('click', async function () {
+ // Use document.documentElement for dark mode detection
+ const isDark = document.documentElement.classList.contains('dark');
+ const hasMemory = trip.hasMemory;
+
+ if (isDark) {
+ if (hasMemory) {
+ // Fetch the topmost memoryId for this trip
+ const tripRef = ref(db, `trips/${trip.tid}/memories`);
+ const snapshot = await get(tripRef);
+ if (snapshot.exists()) {
+ const memoryIds = Object.keys(snapshot.val());
+ if (memoryIds.length > 0) {
+ const topMemoryId = memoryIds[0];
+ goto(`/viewimage/${trip.tid}/${topMemoryId}`);
+ }
+ }
+ } else {
+ // Show NewMemoryPopup for this trip
+ selectedTripIdForMemory = trip.tid;
+ showNewMemoryPopup = true;
+ }
+ } else {
+ // Default: go to itinerary
+ goto(`/itinerary/${trip.tid}`);
+ }
});
markerGroup.append('text')
@@ -187,8 +214,32 @@
.attr('class', 'trip-label')
.text(`${formatDate(trip.startDate)} - ${formatDate(trip.endDate)}`)
.style('cursor', 'pointer')
- .on('click', function () {
- goto(`/itinerary/${trip.tid}`);
+ .on('click', async function () {
+ // Use document.documentElement for dark mode detection
+ const isDark = document.documentElement.classList.contains('dark');
+ const hasMemory = trip.hasMemory;
+
+ if (isDark) {
+ if (hasMemory) {
+ // Fetch the topmost memoryId for this trip
+ const tripRef = ref(db, `trips/${trip.tid}/memories`);
+ const snapshot = await get(tripRef);
+ if (snapshot.exists()) {
+ const memoryIds = Object.keys(snapshot.val());
+ if (memoryIds.length > 0) {
+ const topMemoryId = memoryIds[0];
+ goto(`/viewimage/${trip.tid}/${topMemoryId}`);
+ }
+ }
+ } else {
+ // Show NewMemoryPopup for this trip
+ selectedTripIdForMemory = trip.tid;
+ showNewMemoryPopup = true;
+ }
+ } else {
+ // Default: go to itinerary
+ goto(`/itinerary/${trip.tid}`);
+ }
});
markerGroup
@@ -235,6 +286,10 @@
+{#if showNewMemoryPopup}
+
showNewMemoryPopup = false} />
+{/if}
+