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:
Wes
2026-08-16 12:19:12 -06:00
parent c6ea385186
commit e17c4df27e
3 changed files with 35 additions and 4 deletions

View File

@@ -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 };

View File

@@ -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],
);