Skip to content

Commit b4e2be5

Browse files
fix: preserve 0.0 coordinates and improve memories UX
1 parent 6b6a6e0 commit b4e2be5

File tree

4 files changed

+17
-29
lines changed

4 files changed

+17
-29
lines changed

backend/app/database/images.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,8 @@ def db_get_all_images_for_memories() -> List[dict]:
889889
"metadata": image_util_parse_metadata(row[4]),
890890
"isTagged": bool(row[5]),
891891
"isFavourite": bool(row[6]),
892-
"latitude": row[7] if row[7] else None, # Can be None
893-
"longitude": row[8] if row[8] else None, # Can be None
892+
"latitude": row[7] if row[7] is not None else None, # Can be None
893+
"longitude": row[8] if row[8] is not None else None, # Can be None
894894
"captured_at": row[9] if row[9] else None,
895895
"tags": row[10].split(",") if row[10] else None,
896896
}

frontend/src/components/Memories/MemoriesPage.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import {
2323
selectAllMemories,
2424
selectMemoriesLoading,
2525
selectMemoriesError,
26-
selectTotalMemoryCount,
2726
} from '@/store/slices/memoriesSlice';
2827
import { MemoryCard } from './MemoryCard';
2928
import { FeaturedMemoryCard } from './FeaturedMemoryCard';
@@ -148,7 +147,6 @@ export const MemoriesPage: React.FC = () => {
148147
const allMemories = useAppSelector(selectAllMemories);
149148
const loading = useAppSelector(selectMemoriesLoading);
150149
const error = useAppSelector(selectMemoriesError);
151-
const totalCount = useAppSelector(selectTotalMemoryCount);
152150

153151
// Simple filter state: 'all' | 'location' | 'date'
154152
const [filter, setFilter] = useState<'all' | 'location' | 'date'>('all');
@@ -158,6 +156,7 @@ export const MemoriesPage: React.FC = () => {
158156
memories.filter((m) => m.image_count >= 2);
159157

160158
// Calculate counts (only memories with 2+ images)
159+
const totalCount = memoriesWithMultipleImages(allMemories).length;
161160
const locationCount = memoriesWithMultipleImages(allMemories).filter(
162161
(m) => m.center_lat != null && m.center_lon != null,
163162
).length;

frontend/src/components/Memories/MemoryDetail.tsx

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,18 @@ export const MemoryDetail = () => {
114114
file_location: img.path,
115115
file_size: 0,
116116
item_type: 'image' as const,
117-
latitude: img.latitude || undefined,
118-
longitude: img.longitude || undefined,
117+
latitude: img.latitude ?? undefined,
118+
longitude: img.longitude ?? undefined,
119119
},
120120
}));
121121

122-
dispatch(setImages(formattedImages));
123-
dispatch(hideLoader());
122+
// Defer setImages and hideLoader to next tick so loader becomes visible
123+
requestAnimationFrame(() => {
124+
dispatch(setImages(formattedImages));
125+
dispatch(hideLoader());
126+
});
124127
}, [memory, dispatch]);
125128

126-
// Refetch memory data when returning to the page to get updated favorite status
127-
useEffect(() => {
128-
// This will cause the component to re-render with fresh data from Redux
129-
// when the user toggles a favorite and the memory data is refetched
130-
return () => {
131-
// Cleanup if needed
132-
};
133-
}, []);
134-
135129
// If memory not found, show error
136130
if (!memory) {
137131
return (

frontend/src/store/slices/memoriesSlice.ts

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,18 +162,13 @@ export const fetchAllMemoriesData = createAsyncThunk<
162162
void,
163163
void,
164164
{ rejectValue: string }
165-
>('memories/fetchAllData', async (_, { dispatch, rejectWithValue }) => {
166-
try {
167-
await Promise.all([
168-
dispatch(fetchOnThisDay()),
169-
dispatch(fetchRecentMemories(30)),
170-
dispatch(fetchYearMemories(365)),
171-
dispatch(fetchAllMemories()),
172-
]);
173-
} catch (error) {
174-
const apiError = error as ApiError;
175-
return rejectWithValue(apiError.message);
176-
}
165+
>('memories/fetchAllData', async (_, { dispatch }) => {
166+
await Promise.all([
167+
dispatch(fetchOnThisDay()),
168+
dispatch(fetchRecentMemories(30)),
169+
dispatch(fetchYearMemories(365)),
170+
dispatch(fetchAllMemories()),
171+
]);
177172
});
178173

179174
// ============================================================================

0 commit comments

Comments
 (0)