mirror of
https://github.com/Zakkaus/doona.git
synced 2026-12-06 00:00:57 +00:00
A connection test that fails before any response was wrapped as HTTP 0 and lost its network and cross-origin advice; it now keeps that advice and links the sign-in troubleshooting section, which covers both and leads on to access from another origin. Offline dependency diagnostics, refused routing templates, locked group edits, refused or failed geodata saves and updates, and lost persistence on System status now link the section that explains the fix, through the existing help popovers, text links and toast actions. The persistence degradations keep the backend's reason in their help, and a geodata update that failed at a lasting stage shows its whole reason there. The links reuse existing sections and labels where one fits, so the lazily loaded catalogue stays within its size budget. Adds the geodata-update anchor to the docs map.
27 lines
1.7 KiB
TypeScript
27 lines
1.7 KiB
TypeScript
import type {ConfigDiagnostic} from '../../api/model';
|
|
import {useCapabilities, useGeodata} from '../../store';
|
|
import {formatList, useLang, useT} from '../../i18n';
|
|
import {docsHref} from './docs';
|
|
import {offlineDependencyCode} from './offlineDependency';
|
|
import {announceGeodataUpdate, geodataNeed, type GeoKind} from './geodataUpdate';
|
|
|
|
export type OfflineFix = {kind: 'download'; busy: boolean; run: () => Promise<boolean>} | {kind: 'docs'; href: string; geodata: boolean};
|
|
|
|
// For diagnostics that name a missing offline dependency, given the geodata kinds the write needs (null while
|
|
// unknown): the geodata files to name in their words, and the way out. A geodata update repairs a file honk has
|
|
// loaded; a file it never loaded has to be installed on the device, which the docs explain. A write needing no
|
|
// geodata lacks some other file, so the docs are offered for offline files in general, not for geodata.
|
|
export function useOfflineFix(diagnostics: ConfigDiagnostic[] | null | undefined, needed: GeoKind[] | null) {
|
|
const t = useT();
|
|
const lang = useLang();
|
|
const geodata = useCapabilities().data?.resources.geodata;
|
|
const active = !!diagnostics?.some(item => offlineDependencyCode(item.code));
|
|
const read = useGeodata(active && !!geodata?.available);
|
|
if (!active) return {missingFiles: undefined, fix: null};
|
|
const {missing, repair} = geodataNeed(needed, geodata, read.data);
|
|
const fix: OfflineFix = repair
|
|
? {kind: 'download', busy: read.busy, run: () => announceGeodataUpdate(read.update(), t, lang)}
|
|
: {kind: 'docs', href: docsHref(lang, 'offline-dependency'), geodata: needed?.length !== 0};
|
|
return {missingFiles: missing.length ? formatList(lang, missing) : undefined, fix};
|
|
}
|