mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-24 07:53:09 +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:
@@ -129,6 +129,13 @@ export function useWandererConnection() {
|
||||
saved?.lastCheckedAt && saved.lastCheckOk === false && saved.lastCheckError
|
||||
? errorText(saved.lastCheckError)
|
||||
: null;
|
||||
/**
|
||||
* Changes whenever the server's view of the connection does: connecting,
|
||||
* disconnecting, a saved token (which clears the last check) or a test that
|
||||
* stored a new result. The watch row re-reads itself on it, since each of
|
||||
* those can lift or set its "token refused" state.
|
||||
*/
|
||||
const checkKey = `${connected}|${saved?.lastCheckedAt ?? ''}|${saved?.lastCheckOk ?? ''}`;
|
||||
|
||||
return {
|
||||
url,
|
||||
@@ -145,6 +152,7 @@ export function useWandererConnection() {
|
||||
tokenInvalid,
|
||||
canSave,
|
||||
lastCheck,
|
||||
checkKey,
|
||||
save,
|
||||
test,
|
||||
disconnect,
|
||||
|
||||
Reference in New Issue
Block a user