Estate: narrow parentId before the Space route lookup; prettier; ignore harness

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-10-31 17:50:52 +01:00
commit 6eae929cd9
3 changed files with 22 additions and 11 deletions

View file

@ -2,4 +2,5 @@ dist
node_modules node_modules
package.json package.json
package-lock.json package-lock.json
LICENSEharness LICENSE
harness

View file

@ -53,7 +53,7 @@ const estateRoomPath = (mx: ReturnType<typeof useMatrixClient>, room: EstateRoom
const alias = getCanonicalAliasOrRoomId(mx, room.roomId); const alias = getCanonicalAliasOrRoomId(mx, room.roomId);
if (room.direct) return getDirectRoomPath(alias); if (room.direct) return getDirectRoomPath(alias);
// A Space the user has not joined has no Space route; the room still resolves from Home. // A Space the user has not joined has no Space route; the room still resolves from Home.
if (mx.getRoom(room.parentId)?.getMyMembership() === 'join') { if (room.parentId && mx.getRoom(room.parentId)?.getMyMembership() === 'join') {
return getSpaceRoomPath(getCanonicalAliasOrRoomId(mx, room.parentId), alias); return getSpaceRoomPath(getCanonicalAliasOrRoomId(mx, room.parentId), alias);
} }
return getHomeRoomPath(alias); return getHomeRoomPath(alias);

View file

@ -196,12 +196,10 @@ describe('buildEstate', () => {
input({ input({
hierarchy: [ hierarchy: [
...hierarchy.slice(0, 2), ...hierarchy.slice(0, 2),
space( space(PROJECTS, 'Projects', ['!cultlib:gamecult.org', '!aeth:gamecult.org'], {
PROJECTS, '!cultlib:gamecult.org': 'eureka',
'Projects', '!aeth:gamecult.org': 'eureka',
['!cultlib:gamecult.org', '!aeth:gamecult.org'], }),
{ '!cultlib:gamecult.org': 'eureka', '!aeth:gamecult.org': 'eureka' }
),
...hierarchy.slice(3, 5), ...hierarchy.slice(3, 5),
], ],
}) })
@ -268,10 +266,20 @@ describe('Elsewhere', () => {
); );
it('lists a joined non-DM room the hierarchy does not return, named from the store', () => { it('lists a joined non-DM room the hierarchy does not return, named from the store', () => {
const t = strays({ strayRoomIds: ['!adhoc:x'], roomNames: new Map([['!adhoc:x', 'Meeting']]) })!; const t = strays({
strayRoomIds: ['!adhoc:x'],
roomNames: new Map([['!adhoc:x', 'Meeting']]),
})!;
expect(t.label).toBe('Elsewhere'); expect(t.label).toBe('Elsewhere');
expect(t.loose).toEqual([ expect(t.loose).toEqual([
{ roomId: '!adhoc:x', name: 'Meeting', state: 'joined', via: [], parentId: null, direct: false }, {
roomId: '!adhoc:x',
name: 'Meeting',
state: 'joined',
via: [],
parentId: null,
direct: false,
},
]); ]);
}); });
@ -292,7 +300,9 @@ describe('Elsewhere', () => {
}); });
it('never lists a room the user has not joined', () => { it('never lists a room the user has not joined', () => {
expect(strays({ membership: new Map([['!adhoc:x', 'invite']]), strayRoomIds: ['!adhoc:x'] })).toBeUndefined(); expect(
strays({ membership: new Map([['!adhoc:x', 'invite']]), strayRoomIds: ['!adhoc:x'] })
).toBeUndefined();
}); });
it('is absent when there are no strays', () => { it('is absent when there are no strays', () => {