From 32c0b169bdbdcdd506eff5b35347473efec326c4 Mon Sep 17 00:00:00 2001 From: maziggy Date: Sun, 19 Apr 2026 13:27:41 +0200 Subject: [PATCH] fix(frontend): thumbnails blank until reload after sign-in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On auth-enabled instances, logging out and back in left the File Manager (and occasionally the Archives page) full of broken thumbnails until a manual page reload. Thumbnail URLs are gated by a short-lived camera stream token that tags cannot send via Authorization headers, so the token is appended as ?token=… at render time. Two races broke this after sign-in: 1. The token query was keyed on ['camera-stream-token'] alone and fired while the user was still on the login page. It 401'd, React Query cached the failure with a 50-minute staleTime, and nothing invalidated it after login — the token never arrived. 2. Even when the token did arrive, the module-level variable holding it was not reactive, so pages that had already rendered kept serving image URLs with no token in them. Fixes: - Include user.id in the query key and gate with `enabled: authEnabled ? !!user : true`. A new sign-in produces a new key and triggers a fresh fetch; no anonymous fetch is cached. - When the token transitions from null to a value, walk the DOM once and update src on every /