fix(jellyseerr): address PR review feedback on TV connect flow

- validateJellyseerrSession: hit the authenticated /auth/me endpoint instead
  of the public /status, and only report "expired" on 401/403. Transient
  failures (offline, 5xx) are treated as valid so a flaky network no longer
  logs the user out. The helper no longer mutates persisted state.
- SearchPage: clear the stale "connected" state via clearAllJellyseerData on
  an expired session, gate the Discover validation effect behind isFocused,
  cancel in-flight validation on unmount, and reset the connect prompt when
  the tab loses focus so it can show again.
- settings.tv (seerr): sync the local server-URL field with settings so a
  late-arriving stored/plugin-locked URL isn't shown stale or overwritten.
- useJellyseerr: add setJellyseerrUser/updateSettings to clearAllJellyseerData
  deps to avoid a stale closure.
- TVJellyseerrSearchResults: scale poster/avatar dimensions and use the
  scaled vertical padding (per review).
- translations: drop manual sv.json keys (Crowdin syncs from en.json).

Claude-Session: https://claude.ai/code/session_016Hhu5DruGLPhdP4LAoy1Xd
This commit is contained in:
Fredrik Burmester
2026-06-30 12:07:42 +02:00
parent e1ac98b597
commit 6a1b34ee17
5 changed files with 68 additions and 34 deletions

View File

@@ -76,8 +76,13 @@ export type JellyseerrSessionStatus =
/**
* Checks whether the persisted Jellyseerr session (user + cookies) is still
* valid by hitting the server status endpoint. Clears local session data if the
* request fails (expired/revoked cookie).
* valid by hitting an authenticated endpoint (`/auth/me`).
*
* Returns `expired` only when the server actually rejects the session
* (HTTP 401/403). Transient failures (network down, server unreachable, 5xx)
* are treated as `valid` so a flaky connection doesn't log the user out. This
* helper does not mutate persisted state — the caller decides whether to clear
* the session (e.g. via `clearAllJellyseerData`).
*/
export async function validateJellyseerrSession(
serverUrl: string,
@@ -91,11 +96,16 @@ export async function validateJellyseerrSession(
try {
const api = new JellyseerrApi(serverUrl);
await api.axios.get(Endpoints.API_V1 + Endpoints.STATUS);
await api.axios.get(Endpoints.API_V1 + Endpoints.AUTH_ME);
return { valid: true };
} catch (error) {
const status = (error as AxiosError)?.response?.status;
// Only an auth rejection means the session is gone. Anything else
// (offline, DNS failure, server error) should not be reported as expired.
if (status === 401 || status === 403) {
return { valid: false, reason: "expired" };
}
return { valid: true };
} catch {
clearJellyseerrStorageData();
return { valid: false, reason: "expired" };
}
}
@@ -123,6 +133,7 @@ export enum Endpoints {
DISCOVER_TV_NETWORK = DISCOVER + TV + NETWORK,
DISCOVER_MOVIES_STUDIO = `${DISCOVER}${MOVIE}s${STUDIO}`,
AUTH_JELLYFIN = "/auth/jellyfin",
AUTH_ME = "/auth/me",
}
export type DiscoverEndpoint =
@@ -480,7 +491,7 @@ export const useJellyseerr = () => {
setJellyseerrUser(undefined);
updateSettings({ jellyseerrServerUrl: undefined });
queryClient.removeQueries({ queryKey: ["search", "jellyseerr"] });
}, [queryClient]);
}, [queryClient, setJellyseerrUser, updateSettings]);
const requestMedia = useCallback(
(title: string, request: MediaRequestBody, onSuccess?: () => void) => {