mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-24 15:51:13 -05:00
Implement API improvements Phases 1-4
This commit is contained in:
@@ -37,14 +37,20 @@ export function useProfileUpdateMutation() {
|
||||
// Cancel outgoing refetches
|
||||
await queryClient.cancelQueries({ queryKey: ['profile', userId] });
|
||||
|
||||
interface Profile {
|
||||
display_name?: string;
|
||||
bio?: string;
|
||||
location_id?: string;
|
||||
website?: string;
|
||||
}
|
||||
|
||||
// Snapshot previous value
|
||||
const previousProfile = queryClient.getQueryData(['profile', userId]);
|
||||
const previousProfile = queryClient.getQueryData<Profile>(['profile', userId]);
|
||||
|
||||
// Optimistically update
|
||||
queryClient.setQueryData(['profile', userId], (old: any) => ({
|
||||
...old,
|
||||
...updates,
|
||||
}));
|
||||
queryClient.setQueryData<Profile>(['profile', userId], (old) =>
|
||||
old ? { ...old, ...updates } : old
|
||||
);
|
||||
|
||||
return { previousProfile, userId };
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user