diff --git a/apps/postcards/src/features/backup/Backup.tsx b/apps/postcards/src/features/backup/Backup.tsx index fa4ea30..1278fe6 100644 --- a/apps/postcards/src/features/backup/Backup.tsx +++ b/apps/postcards/src/features/backup/Backup.tsx @@ -197,7 +197,7 @@ export function Backup() { setMessage({ kind: "err", text: result.error }); return; } - if (visits.length > 0 || trips.length > 0 || stories.length > 0) { + if (hasData) { const ok = window.confirm( t("backup.confirm.replace", { curPlaces: visits.length, diff --git a/apps/postcards/src/features/guides/GuideButton.tsx b/apps/postcards/src/features/guides/GuideButton.tsx index 149709d..889cc7b 100644 --- a/apps/postcards/src/features/guides/GuideButton.tsx +++ b/apps/postcards/src/features/guides/GuideButton.tsx @@ -24,6 +24,9 @@ const KIND_GROUP: Record = { }; const GROUP_ORDER = ["explore", "understand", "phrasebook"] as const; +/** Whether the device is offline right now (guides are online-only, opt-in). */ +const isOffline = () => typeof navigator !== "undefined" && !navigator.onLine; + /** Resolve the names a place's guides are built from (common country name — * the real Wikivoyage article title, e.g. "Russia", not "Russian Federation"). */ function guideNames(place: PlaceRef) { @@ -203,7 +206,7 @@ function GuideContent({ placeName, names }: { placeName: string; names: GuideNam const tried = useRef(false); useEffect(() => { if (tried.current || summary || wpSummary || !autoLoad) return; - if (typeof navigator !== "undefined" && !navigator.onLine) return; + if (isOffline()) return; tried.current = true; void loadOverview(); // eslint-disable-next-line react-hooks/exhaustive-deps @@ -271,7 +274,7 @@ function GuideContent({ placeName, names }: { placeName: string; names: GuideNam )} {!overview && state === "empty" && (

- {typeof navigator !== "undefined" && !navigator.onLine + {isOffline() ? t("guide.emptyOffline") : t("guide.emptyOnline")}{" "}