Skip to content

Commit daeaf7c

Browse files
authored
Refine channel lifecycle settings (#2427)
1 parent 80244f8 commit daeaf7c

14 files changed

Lines changed: 853 additions & 484 deletions

‎desktop/src/features/channels/hooks.ts‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,10 @@ export function useUpdateChannelMutation(channelId: string | null) {
348348

349349
return updateChannel({ ...input, channelId });
350350
},
351+
onMutate: () => ({ channelId }),
351352
onSuccess: (updatedChannel) => {
352-
if (!channelId) {
353-
return;
354-
}
355-
356353
queryClient.setQueryData<ChannelDetail>(
357-
channelDetailQueryKey(channelId),
354+
channelDetailQueryKey(updatedChannel.id),
358355
updatedChannel,
359356
);
360357
queryClient.setQueryData<Channel[]>(channelsQueryKey, (current = []) =>
@@ -365,17 +362,17 @@ export function useUpdateChannelMutation(channelId: string | null) {
365362
),
366363
);
367364
},
368-
onSettled: () => {
365+
onSettled: (_data, _error, _variables, context) => {
369366
// refetchType "none": onSuccess already cached the relay-returned detail;
370367
// awaiting the full channel-list refetch kept the edit dialog stuck on
371368
// "Saving..." (same failure #1360 fixed for create).
372369
void queryClient.invalidateQueries({
373370
queryKey: channelsQueryKey,
374371
refetchType: "none",
375372
});
376-
if (channelId) {
373+
if (context?.channelId) {
377374
void queryClient.invalidateQueries({
378-
queryKey: channelDetailQueryKey(channelId),
375+
queryKey: channelDetailQueryKey(context.channelId),
379376
refetchType: "none",
380377
});
381378
}

0 commit comments

Comments
 (0)