@@ -8,11 +8,12 @@ import {
88 getDirectRoomPath ,
99 getHomeForumPath ,
1010 getHomeRoomPath ,
11- getSpacePath ,
1211 getSpaceForumPath ,
12+ getSpacePath ,
1313 getSpaceRoomPath ,
1414 resolveSection ,
1515} from '$pages/pathUtils' ;
16+ import { CustomRoomType } from '$types/matrix/room' ;
1617import { getOrphanParents , guessPerfectParent } from '$utils/room/hierarchy' ;
1718import { roomToParentsAtom } from '$state/room/roomToParents' ;
1819import { mDirectAtom } from '$state/mDirectList' ;
@@ -21,7 +22,6 @@ import { settingsAtom } from '$state/settings';
2122import { useSetting } from '$state/hooks/settings' ;
2223import { useSelectedSpace } from './router/useSelectedSpace' ;
2324import { useMatrixClient } from './useMatrixClient' ;
24- import { CustomRoomType } from '$types/matrix/room' ;
2525
2626export const useRoomNavigate = ( ) => {
2727 const navigate = useNavigate ( ) ;
@@ -44,9 +44,10 @@ export const useRoomNavigate = () => {
4444 ( roomId : string , eventId ?: string , opts ?: NavigateOptions ) => {
4545 const roomIdOrAlias = getCanonicalAliasOrRoomId ( mx , roomId ) ;
4646 const openSpaceTimeline = developerTools && spaceSelectedId === roomId ;
47- const isForum = mx . getRoom ( roomId ) ?. getType ( ) === CustomRoomType . Forum ;
4847
4948 const orphanParents = openSpaceTimeline ? [ roomId ] : getOrphanParents ( roomToParents , roomId ) ;
49+ // The forum view has no jump target, so an event jump still uses the room path.
50+ const forum = ! eventId && mx . getRoom ( roomId ) ?. getType ( ) === CustomRoomType . Forum ;
5051 let destPath : string ;
5152 let roomPart : string ;
5253 if ( orphanParents . length > 0 ) {
@@ -59,19 +60,15 @@ export const useRoomNavigate = () => {
5960
6061 const pSpaceIdOrAlias = getCanonicalAliasOrRoomId ( mx , parentSpace ) ;
6162 roomPart = openSpaceTimeline ? roomId : roomIdOrAlias ;
62- destPath = isForum
63- ? getSpaceForumPath ( pSpaceIdOrAlias , roomPart , eventId )
63+ destPath = forum
64+ ? getSpaceForumPath ( pSpaceIdOrAlias , roomPart )
6465 : getSpaceRoomPath ( pSpaceIdOrAlias , roomPart , eventId ) ;
6566 } else if ( mDirects . has ( roomId ) ) {
6667 roomPart = roomIdOrAlias ;
67- destPath = isForum
68- ? getDirectForumPath ( roomPart , eventId )
69- : getDirectRoomPath ( roomPart , eventId ) ;
68+ destPath = forum ? getDirectForumPath ( roomPart ) : getDirectRoomPath ( roomPart , eventId ) ;
7069 } else {
7170 roomPart = roomIdOrAlias ;
72- destPath = isForum
73- ? getHomeForumPath ( roomPart , eventId )
74- : getHomeRoomPath ( roomPart , eventId ) ;
71+ destPath = forum ? getHomeForumPath ( roomPart ) : getHomeRoomPath ( roomPart , eventId ) ;
7572 }
7673
7774 const section = resolveSection ( destPath ) ;
0 commit comments