mirror of
https://github.com/Zakkaus/doona.git
synced 2026-12-06 00:00:57 +00:00
refactor(ui): unify confirmations, retries and labels
Share confirmation dialogs, formatters, cards and menus across features. Make failed reads retryable, correct cancellation behavior and standardize terminology and status text.
This commit is contained in:
1 parent
6ec531e9c4
commit
c7ec045bb2
191 files changed
+2324
-1685
No files matched your search
@@ -42,14 +42,31 @@ export function useShellController(initial: Lang) {
|
||||
}
|
||||
);
|
||||
}, []);
|
||||
// The dialog opens once its chunk is here; a chunk that fails leaves nothing open.
|
||||
// The dialog opens once its chunk is here; a chunk that fails leaves nothing open. Escape, a close or a newer
|
||||
// request while the chunk loads drops the request, so the dialog never opens after the user has moved on.
|
||||
const searchRequest = useRef(0);
|
||||
const openSearch = useCallback(() => {
|
||||
const request = ++searchRequest.current;
|
||||
searchDialog.preload().then(
|
||||
() => setSearchOpen(true),
|
||||
() => toast('negative', translate(shown.current, 'shell.searchUnavailable'))
|
||||
() => {
|
||||
if (searchRequest.current === request) setSearchOpen(true);
|
||||
},
|
||||
() => {
|
||||
if (searchRequest.current === request) toast('negative', translate(shown.current, 'shell.searchUnavailable'));
|
||||
}
|
||||
);
|
||||
}, []);
|
||||
const closeSearch = useCallback(() => setSearchOpen(false), []);
|
||||
const closeSearch = useCallback(() => {
|
||||
searchRequest.current++;
|
||||
setSearchOpen(false);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
const onKey = (event: KeyboardEvent) => {
|
||||
if (event.key === 'Escape') searchRequest.current++;
|
||||
};
|
||||
addEventListener('keydown', onKey);
|
||||
return () => removeEventListener('keydown', onKey);
|
||||
}, []);
|
||||
const navigate = useCallback(
|
||||
(href: string) => {
|
||||
const next = parseHash(href);
|
||||
@@ -64,10 +81,9 @@ export function useShellController(initial: Lang) {
|
||||
document.fonts?.load(`14px '${lang === 'zh-CN' ? 'Noto Sans SC' : 'Noto Sans TC'}'`, sample).catch(() => {});
|
||||
}, [lang]);
|
||||
useEffect(warmAllPages, []);
|
||||
// react-aria records every element with a running CSS transition and forgets it on transitionend or
|
||||
// transitioncancel, neither of which a removed element receives. A page left mid-transition (a tab marker sliding, a
|
||||
// colour fading) therefore stayed in that record with its whole detached tree, 0.3 to 0.7 MiB per round of the
|
||||
// pages. runAfterTransition drops the disconnected entries before it runs its callback.
|
||||
// react-aria tracks elements with a running CSS transition until transitionend or transitioncancel, which a removed
|
||||
// element never receives, so a page left mid-transition would keep its detached tree. runAfterTransition drops
|
||||
// disconnected entries first.
|
||||
useEffect(() => {
|
||||
runAfterTransition(() => {});
|
||||
}, [route]);
|
||||
@@ -94,6 +110,8 @@ export function useStartupToasts() {
|
||||
sessionStorage.removeItem('doona-saved');
|
||||
toast('positive', t('ui.saved'));
|
||||
}
|
||||
} catch {}
|
||||
} catch {
|
||||
/* Storage can be unavailable. */
|
||||
}
|
||||
}, [t]);
|
||||
}
|
||||
Reference in new issue
Block a user