mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 11:36:05 +00:00
fix(tours): refresh the wanderer watch after a fixed token and truly disable its switch offline
The watch row only re-read its state when the connection came or went, so after a passing connection test or a newly saved token it kept saying "Token refused" until a reload. The connection card now hands it a key built from the saved connection and its last check, and the row re-reads the watch whenever that changes. Without a connection the switch was only dimmed: the button stayed in the tab order and was announced as active. ToggleSwitch gains a disabled prop that disables the button and marks it aria-disabled, and the reason stays reachable through a focusable wrapper carrying the tooltip.
This commit is contained in:
@@ -43,12 +43,14 @@ export function watchStatusOf(
|
||||
|
||||
/**
|
||||
* WAN-02: the background watch in the wanderer card. It loads with the card
|
||||
* and again whenever the connection comes or goes, switches on and off at
|
||||
* and again whenever `refreshKey` changes, which the connection card bumps on
|
||||
* connecting, disconnecting, saving a token and a stored test result, so a
|
||||
* refused token clears once it is fixed. It switches on and off at
|
||||
* once (there is nothing to save with the form), and opens the tour a hint is
|
||||
* about. Online-only like the rest of the connection: the watch runs on the
|
||||
* server and its hints are read from there.
|
||||
*/
|
||||
export function useWandererWatch(connected: boolean) {
|
||||
export function useWandererWatch(refreshKey: string) {
|
||||
const { t, locale } = useTranslation();
|
||||
const toast = useToast();
|
||||
const navigate = useNavigate();
|
||||
@@ -71,7 +73,7 @@ export function useWandererWatch(connected: boolean) {
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [connected]);
|
||||
}, [refreshKey]);
|
||||
|
||||
const toggle = useCallback(async () => {
|
||||
if (!watch?.connected || saving) return;
|
||||
|
||||
Reference in New Issue
Block a user