diff --git a/.prettierignore b/.prettierignore index e0aa18a1..3a4d7da1 100644 --- a/.prettierignore +++ b/.prettierignore @@ -2,4 +2,4 @@ dist node_modules package.json package-lock.json -LICENSE \ No newline at end of file +LICENSEharness diff --git a/src/app/features/estate/EstateNavigator.tsx b/src/app/features/estate/EstateNavigator.tsx index 90b3e529..1087c015 100644 --- a/src/app/features/estate/EstateNavigator.tsx +++ b/src/app/features/estate/EstateNavigator.tsx @@ -44,10 +44,10 @@ import { roomToUnreadAtom } from '../../state/room/roomToUnread'; import { AsyncStatus, useAsyncCallback } from '../../hooks/useAsyncCallback'; import { EstateRoom, EstateTier } from './buildEstate'; import { activateEstateRoom, awaitMyJoin } from './joinEstateRoom'; +import { useEstate, useEstateRootId } from './useEstate'; /** How long a tap waits for the client store to hold the room it just joined. */ const JOIN_ARRIVAL_TIMEOUT_MS = 20000; -import { useEstate, useEstateRootId } from './useEstate'; const estateRoomPath = (mx: ReturnType, room: EstateRoom): string => { const alias = getCanonicalAliasOrRoomId(mx, room.roomId); diff --git a/src/app/features/estate/buildEstate.test.ts b/src/app/features/estate/buildEstate.test.ts index bdc47e5c..29c58048 100644 --- a/src/app/features/estate/buildEstate.test.ts +++ b/src/app/features/estate/buildEstate.test.ts @@ -90,7 +90,7 @@ describe('buildEstate', () => { expect(tiers.flatMap((t) => [...t.loose, ...t.groups.flatMap((g) => g.rooms)])).toHaveLength(4); }); - it('groups rooms by steward Mind from the steward on each room's Space child entry', () => { + it('groups rooms by steward Mind from the steward on each Space child entry', () => { const projects = buildEstate(input()).find((t) => t.id === PROJECTS)!; expect(projects.groups.map((g) => [g.mind, g.rooms.map((r) => r.roomId)])).toEqual([ ['eureka', ['!cultlib:gamecult.org']], diff --git a/src/app/features/estate/buildEstate.ts b/src/app/features/estate/buildEstate.ts index 9edbf548..b9232beb 100644 --- a/src/app/features/estate/buildEstate.ts +++ b/src/app/features/estate/buildEstate.ts @@ -12,14 +12,6 @@ * invited-only member can read (she cannot read the Space's state). */ -export type EstateHierarchyRoom = { - room_id: string; - name?: string; - canonical_alias?: string; - room_type?: string; - children_state?: { state_key: string; content?: SpaceChildContent }[]; -}; - export const STEWARD_KEY = 'org.gamecult.steward'; export type SpaceChildContent = { @@ -28,6 +20,14 @@ export type SpaceChildContent = { [STEWARD_KEY]?: { mind?: unknown }; }; +export type EstateHierarchyRoom = { + room_id: string; + name?: string; + canonical_alias?: string; + room_type?: string; + children_state?: { state_key: string; content?: SpaceChildContent }[]; +}; + export type EstateMembership = 'joined' | 'invited' | 'joinable'; export type EstateRoom = { diff --git a/src/app/features/estate/joinEstateRoom.ts b/src/app/features/estate/joinEstateRoom.ts index bec13126..df5284e3 100644 --- a/src/app/features/estate/joinEstateRoom.ts +++ b/src/app/features/estate/joinEstateRoom.ts @@ -50,14 +50,15 @@ export const awaitMyJoin = ( resolve(true); return; } - const finish = (joined: boolean) => { - clearTimeout(timer); - mx.off('Room.myMembership', onMembership); - resolve(joined); - }; + let finish: (joined: boolean) => void = () => undefined; const onMembership = (room: { roomId: string }, membership: string) => { if (room.roomId === roomId && membership === 'join') finish(true); }; const timer = setTimeout(() => finish(false), timeoutMs); + finish = (joined) => { + clearTimeout(timer); + mx.off('Room.myMembership', onMembership); + resolve(joined); + }; mx.on('Room.myMembership', onMembership); });