mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 00:43:15 +00:00
feat(places): notes, visits, tours, history, tags and location in the place sheet, saved lists on the trip map
Both the desktop sheet and the phone sheet of All places show the place's location as a badge, its notes per list, its visits from trips (hidden without any), linked tours and bookings, its change history and the reader's own tags with a tag filter. A trip map can show the places of linked lists and add one to the trip. All places reloads after a list is added or removed.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { useEffect, useMemo } from 'react';
|
||||
|
||||
import { tripVisitedEntry, usePlaceVisitsStore, watchPlaceVisits } from '../store/placeVisitsStore';
|
||||
|
||||
/**
|
||||
* The places of a trip the reader confirmed a visit at (PLC-23), there or at the
|
||||
* same place elsewhere, for the "visited" choice of the place list and the map.
|
||||
* Read when the trip opens and again whenever a visit changes; offline it stays
|
||||
* empty, so the choice simply is not offered.
|
||||
*/
|
||||
export function useTripVisitedIds(tripId: number | null | undefined): ReadonlySet<number> {
|
||||
const entry = usePlaceVisitsStore((s) => tripVisitedEntry(s, tripId));
|
||||
const load = usePlaceVisitsStore((s) => s.loadTripVisited);
|
||||
|
||||
useEffect(() => watchPlaceVisits(), []);
|
||||
useEffect(() => {
|
||||
if (tripId == null) return;
|
||||
load(tripId).catch(() => {
|
||||
// Offline or without access: no visited places to offer.
|
||||
return undefined;
|
||||
});
|
||||
}, [tripId, load]);
|
||||
|
||||
const ids = entry?.placeIds;
|
||||
return useMemo(() => new Set(ids ?? []), [ids]);
|
||||
}
|
||||
Reference in New Issue
Block a user