fix(notifications): use orphan parent space for deep-link navigation
useNotificationJumper was using roomToParents.get(roomId) — the direct parent set — which could be a subspace rather than a root-level space. The router only recognises /space/<root-space-id>/room paths, so linking via a subspace ID would hit JoinBeforeNavigate instead of opening the room. Replace with the same logic as useRoomNavigate: getOrphanParents() walks the full hierarchy to find root-level spaces, guessPerfectParent() picks the best one to route through.
This commit is contained in:
1 parent
7041c7e62a
commit
0d4d449d5e
1 file changed
+8
-4
@@ -8,6 +8,7 @@ import { useSyncState } from './useSyncState';
|
||||
import { useMatrixClient } from './useMatrixClient';
|
||||
import { getCanonicalAliasOrRoomId } from '../utils/matrix';
|
||||
import { getDirectRoomPath, getHomeRoomPath, getSpaceRoomPath } from '../pages/pathUtils';
|
||||
import { getOrphanParents, guessPerfectParent } from '../utils/room';
|
||||
import { roomToParentsAtom } from '../state/room/roomToParents';
|
||||
import { createLogger } from '../utils/debug';
|
||||
|
||||
@@ -62,12 +63,15 @@ export function NotificationJumper() {
|
||||
// If the room lives inside a space, route through the space path so
|
||||
// SpaceRouteRoomProvider can resolve it — HomeRouteRoomProvider only
|
||||
// knows orphan rooms and would show JoinBeforeNavigate otherwise.
|
||||
const parents = roomToParents.get(pending.roomId);
|
||||
const firstParentId = parents && [...parents][0];
|
||||
if (firstParentId) {
|
||||
// Use getOrphanParents + guessPerfectParent (same as useRoomNavigate) so
|
||||
// we always navigate to a root-level space, not a subspace — subspace
|
||||
// paths are not recognised by the router and land on JoinBeforeNavigate.
|
||||
const orphanParents = getOrphanParents(roomToParents, pending.roomId);
|
||||
if (orphanParents.length > 0) {
|
||||
const parentSpace = guessPerfectParent(mx, pending.roomId, orphanParents) ?? orphanParents[0];
|
||||
navigate(
|
||||
getSpaceRoomPath(
|
||||
getCanonicalAliasOrRoomId(mx, firstParentId),
|
||||
getCanonicalAliasOrRoomId(mx, parentSpace),
|
||||
roomIdOrAlias,
|
||||
pending.eventId
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user