@@ -1797,17 +1797,22 @@ export default function SidebarV2() {
17971797 ( threadKey : string , coParkingKeys ?: ReadonlySet < string > ) : ( ( ) => void ) | null => {
17981798 if ( routeThreadKeyRef . current !== threadKey ) return null ;
17991799 const shell = allThreadByKeyRef . current . get ( threadKey ) ;
1800- const orderedKeys = orderedThreadKeysRef . current ;
1801- const settledKeys = settledThreadKeysRef . current ;
1802- const snoozedKeys = snoozedThreadKeysRef . current ;
1803- const currentIndex = orderedKeys . indexOf ( threadKey ) ;
1804- const nextCardKey =
1805- currentIndex === - 1
1806- ? null
1807- : ( [ ...orderedKeys . slice ( currentIndex + 1 ) , ...orderedKeys . slice ( 0 , currentIndex ) ] . find (
1808- ( key ) => ! settledKeys . has ( key ) && ! snoozedKeys . has ( key ) && ! coParkingKeys ?. has ( key ) ,
1809- ) ?? null ) ;
1810- const nextThread = nextCardKey ? threadByKeyRef . current . get ( nextCardKey ) : null ;
1800+ const navigationNow = new Date ( ) . toISOString ( ) ;
1801+ const nextThreadKey = resolveNextActiveThreadIdAfterSettle ( {
1802+ threadIds : orderedThreadKeysRef . current ,
1803+ fallbackThreadIds : allUnarchivedThreadKeysRef . current ,
1804+ settledThreadId : threadKey ,
1805+ isActive : ( candidateKey ) => {
1806+ const candidate = allThreadByKeyRef . current . get ( candidateKey ) ;
1807+ return (
1808+ candidate !== undefined &&
1809+ ! coParkingKeys ?. has ( candidateKey ) &&
1810+ ! isThreadEffectivelySnoozedRef . current ( candidate , navigationNow ) &&
1811+ ! isThreadEffectivelySettledRef . current ( candidate )
1812+ ) ;
1813+ } ,
1814+ } ) ;
1815+ const nextThread = nextThreadKey ? allThreadByKeyRef . current . get ( nextThreadKey ) : null ;
18111816 return nextThread
18121817 ? ( ) => navigateToThread ( scopeThreadRef ( nextThread . environmentId , nextThread . id ) )
18131818 : shell
0 commit comments