mirror of
https://github.com/block/buzz.git
synced 2026-11-06 17:31:19 +00:00
fix(desktop): cancel superseded channel reselect
Return huddle navigation promises so deferred navigation can clear its skeleton when route commits fail, and cover reselecting the current channel while a new channel is pending. Co-authored-by: Carl <c7ebe626f000404285d3686e1dc74cc07cc60a9754a150041ba132e14bd3e2ec@buzz.block.builderlab.xyz> Signed-off-by: Wes <wesbillman@users.noreply.github.com>
This commit is contained in:
@@ -78,7 +78,12 @@ export function useDeferredSidebarNavigation({
|
||||
const selectDeferred = React.useCallback(
|
||||
(channelId: string) => {
|
||||
if (channelId === selectedChannelId) {
|
||||
selectChannel(channelId);
|
||||
if (pendingChannelId !== null) {
|
||||
dispatchNavigationIntent();
|
||||
cancel();
|
||||
}
|
||||
const navigationResult = selectChannel(channelId);
|
||||
if (navigationResult) void navigationResult.catch(() => undefined);
|
||||
return;
|
||||
}
|
||||
dispatchNavigationIntent();
|
||||
@@ -122,7 +127,7 @@ export function useDeferredSidebarNavigation({
|
||||
});
|
||||
});
|
||||
},
|
||||
[cancel, selectChannel, selectedChannelId],
|
||||
[cancel, pendingChannelId, selectChannel, selectedChannelId],
|
||||
);
|
||||
|
||||
return { pendingChannelId, selectDeferred };
|
||||
|
||||
@@ -298,7 +298,7 @@ export function useHuddlePresentation() {
|
||||
void queryClient.invalidateQueries({
|
||||
queryKey: channelWindowKey(ephemeralChannelId),
|
||||
});
|
||||
void goChannel(ephemeralChannelId);
|
||||
return goChannel(ephemeralChannelId);
|
||||
},
|
||||
[goChannel, queryClient, revealHuddleChannel],
|
||||
);
|
||||
@@ -306,7 +306,7 @@ export function useHuddlePresentation() {
|
||||
(ephemeralChannelId: string) => {
|
||||
activeHuddleChannelIdRef.current = ephemeralChannelId;
|
||||
trackHuddleBackingChannel(ephemeralChannelId);
|
||||
viewHuddleChannel(ephemeralChannelId);
|
||||
return viewHuddleChannel(ephemeralChannelId);
|
||||
},
|
||||
[trackHuddleBackingChannel, viewHuddleChannel],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user