mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 03:26:07 +00:00
ed18c37903
Every file the release touches was read once more, and what survived an independent check against the code is fixed here, with a test for each. Data and credentials - A document sync connection edited to a new address no longer carries the stored token along: a blank form under another origin is refused, the same rule the probe route already had. Dawarich and AirTrail testConnection send the stored key only to the host it was stored for. - The key rotation script now covers document_connections.secrets and trip_document_links.webhook_secret, which it had skipped. - Turning a booked night into a pause in the road trip popup asks first and says that the booking and its expense go with it. Deleting a place says the same when a night is booked there, on the desktop and on the phone. - A moved version marker over unchanged bytes no longer replaces the TREK file and its attachments; a real revision carries the attachments over. Planner - A drop in the day plan names the row it lands ahead of in the full day, so a hidden hotel stop no longer shifts it one slot early; the store sorts before it splices. Via re-anchoring, the booked-night guard and the sidebar's day membership read the stored day, the index space the server uses. - A hotel stop placed mid-day re-pins the road trip vias of that day, and the booking session receives the new stop order too. The Public API and the iCal feed list a booked hotel once. A plugin can no longer write a stay against another trip's day. Road trip and map - The route overview paces its requests to the public routers and retries a rate limit, and it says which legs it could not route instead of quietly reporting a shorter trip. A click on a via handle no longer drops a second via; handles hide when zooming out. Read-only members cannot edit the driving limits. The phone shows a way back when no day is picked and prints the night drive departure in the chosen clock format. Integrations and search - Google transit keeps conventional trains when the train chip is on. TREK_PLACES_ENABLED=false stops the details and enrichment calls too, and accepts the whole boolean family. A caller-supplied description no longer lands in the instance-wide enrichment cache. Nominatim searches carry a timeout. An OSM place id is checked for shape before it reaches Overpass. - Dawarich puts a stay on the trip whose dates hold it, the Atlas hand-off knows what the Atlas already shows, and a host change with a new key clears the old instance's state. - Document sync: a webhook address pasted by hand works on the token alone, deleting a connection unregisters its subscriptions, Nextcloud under a sub-path connects, Synology answers a name collision before uploading and verifies a move into the bin, Paperless titles are capped at 128 characters, a DNS failure reads as unreachable rather than as a policy verdict, videos from the store are accepted like uploads, and remote_missing has a way out. Conflict buttons only for the owner, a refused choice is reported, a refused credential gets a Reconnect button, disconnecting asks first on the desktop as it does on the phone, and the folder picker no longer spins forever. Release - The server holds the release notice back from a bundle that cannot draw it, so the previous shell served from the service worker cache after an update no longer shows bare keys and no longer lets a click use the notice up. - Import into an existing list gets the same body limit as a new list. Chat images say when the limit is reached and the new controls are translated. The transit backend switch reports a failed save. The Helm chart carries the Amap credentials in its Secret; the shipped templates document the Places API and Amap variables and the Overpass default. The wiki follows.
94 lines
4.3 KiB
TypeScript
94 lines
4.3 KiB
TypeScript
import { useEffect, useState } from 'react';
|
|
import { useSystemNoticeStore, type SystemNoticeDTO } from '../../store/systemNoticeStore.js';
|
|
import { useTranslation } from '../../i18n/index.js';
|
|
import { ModalRenderer } from './SystemNoticeModal.js';
|
|
import { BannerRenderer, ToastRenderer } from './SystemNoticeBanner.js';
|
|
|
|
// Mobile breakpoint matches the modal sheet's (max-width: 639px).
|
|
function useIsMobile() {
|
|
const [isMobile, setIsMobile] = useState(
|
|
() => typeof window !== 'undefined' && (window.matchMedia?.('(max-width: 639px)')?.matches ?? false)
|
|
);
|
|
useEffect(() => {
|
|
const mq = window.matchMedia?.('(max-width: 639px)');
|
|
if (!mq) return;
|
|
const handler = (e: MediaQueryListEvent) => setIsMobile(e.matches);
|
|
mq.addEventListener('change', handler);
|
|
return () => mq.removeEventListener('change', handler);
|
|
}, []);
|
|
return isMobile;
|
|
}
|
|
|
|
/**
|
|
* A key by its shape: dotted, no spaces, `system_notice.release_notes.headline`.
|
|
*
|
|
* A notice may carry literal copy instead of a key — an instance's own announcement is
|
|
* written out, not translated — and `t()` hands any string it does not know straight back,
|
|
* so the test below cannot tell "no translation" from "this IS the text" on its own. The
|
|
* shape can: a sentence has spaces and no dots between words.
|
|
*/
|
|
const KEY_SHAPE = /^[a-z0-9_-]+(\.[a-z0-9_-]+)+$/i;
|
|
|
|
/**
|
|
* Whether a notice has words to show, rather than the names of strings this build lacks.
|
|
*
|
|
* The keys come from the server's registry, the copy from the bundle in the browser, and a
|
|
* deploy parts the two for as long as it takes the page to reload: the service worker keeps
|
|
* serving the old app while `/api/config` already reports the new version, and the release
|
|
* notice for that very version arrives naming keys the old bundle never had. What is drawn
|
|
* is then `system_notice.release_notes.headline` where the headline belongs, on the one
|
|
* notice whose whole job is to be read once per release. Worse, a dismissal in that window
|
|
* is a real one: it is `per-version`, so whoever closes the gibberish never sees the notes.
|
|
*
|
|
* So a notice made only of unresolved keys waits. Nothing is spent by waiting — a notice is
|
|
* used up by `POST /dismiss` and by nothing else — and `App.tsx` reloads the page as soon
|
|
* as the new worker takes over, after which this returns true and the modal opens for real.
|
|
*
|
|
* Deliberately generous: one resolved key is enough. Half a translation is still readable,
|
|
* and a notice hidden by mistake is a worse failure than an ugly one.
|
|
*
|
|
* A bundle older than this filter cannot run it, so the server holds the release notice
|
|
* back until the store announces the layout (see systemNoticeStore.fetch). This filter is
|
|
* for the bundles after that one: they announce the layout but may still lack the copy.
|
|
*/
|
|
function hasCopy(notice: SystemNoticeDTO, t: (key: string) => string): boolean {
|
|
const keys = notice.release
|
|
? [notice.release.headlineKey, notice.release.introKey, notice.release.note.titleKey]
|
|
: [notice.titleKey, notice.bodyKey];
|
|
return keys.some(key => !KEY_SHAPE.test(key) || t(key) !== key);
|
|
}
|
|
|
|
export function SystemNoticeHost() {
|
|
const { notices, loaded } = useSystemNoticeStore();
|
|
const { t } = useTranslation();
|
|
const isMobile = useIsMobile();
|
|
|
|
// Notices are fetched by authStore after login (see App.tsx / authStore modification).
|
|
// Cold-session fetch (page reload with valid session) is triggered here:
|
|
useEffect(() => {
|
|
// Only fetch if not already loaded (authStore may have already triggered)
|
|
if (!loaded) {
|
|
useSystemNoticeStore.getState().fetch();
|
|
}
|
|
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
|
|
|
if (!loaded) return null;
|
|
|
|
// desktopOnly notices (e.g. the thank-you/support modal) are hidden on mobile, and a
|
|
// notice whose copy this build does not have yet waits for the reload (see hasCopy).
|
|
const readable = notices.filter(n => hasCopy(n, t));
|
|
const visible = isMobile ? readable.filter(n => !n.desktopOnly) : readable;
|
|
|
|
const modals = visible.filter(n => n.display === 'modal');
|
|
const banners = visible.filter(n => n.display === 'banner');
|
|
const toasts = visible.filter(n => n.display === 'toast');
|
|
|
|
return (
|
|
<>
|
|
<BannerRenderer notices={banners} />
|
|
<ModalRenderer notices={modals} />
|
|
<ToastRenderer notices={toasts} />
|
|
</>
|
|
);
|
|
}
|