fix(frontend): avatar history strip fills in without a reload

addAvatarHistory was fired off without awaiting, then the history tick was
bumped immediately, so the strip re-read IndexedDB before the write landed and
only populated after a remount. Await the write before bumping the tick.
This commit is contained in:
loki5512344 2026-09-29 10:14:18 +02:00
parent b496bde701
commit e8b77fb0a5
Signed by: boba
GPG key ID: 253067914055423B

View file

@ -25,9 +25,11 @@ export function AvatarUpload({ onReady }: { onReady?: (acceptFile: (file: File)
const [historyTick, setHistoryTick] = useState(0) const [historyTick, setHistoryTick] = useState(0)
const mutation = useMutation({ const mutation = useMutation({
mutationFn: (file: File) => uploadAvatarWithProgress(file, setProgress), mutationFn: (file: File) => uploadAvatarWithProgress(file, setProgress),
onSuccess: (_data, file) => { onSuccess: async (_data, file) => {
client.invalidateQueries({ queryKey: ['me'] }) client.invalidateQueries({ queryKey: ['me'] })
void addAvatarHistory(file) // Await the write before bumping the tick, otherwise the history strip
// re-reads IndexedDB too early and only fills in after a remount (F5).
await addAvatarHistory(file).catch(() => undefined)
setHistoryTick((n) => n + 1) setHistoryTick((n) => n + 1)
setPicked(undefined) setPicked(undefined)
setProgress(null) setProgress(null)