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:
parent
b496bde701
commit
e8b77fb0a5
1 changed files with 4 additions and 2 deletions
|
|
@ -25,9 +25,11 @@ export function AvatarUpload({ onReady }: { onReady?: (acceptFile: (file: File)
|
|||
const [historyTick, setHistoryTick] = useState(0)
|
||||
const mutation = useMutation({
|
||||
mutationFn: (file: File) => uploadAvatarWithProgress(file, setProgress),
|
||||
onSuccess: (_data, file) => {
|
||||
onSuccess: async (_data, file) => {
|
||||
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)
|
||||
setPicked(undefined)
|
||||
setProgress(null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue