Spruce up home page navigation

This commit is contained in:
Jon Staab
2024-12-10 13:02:41 -08:00
parent a65f6f6323
commit 66f3686ef4
4 changed files with 48 additions and 34 deletions
+17
View File
@@ -605,6 +605,9 @@ export const displayChannel = (url: string, room: string) => {
return channelsById.get().get(makeChannelId(url, room))?.name || room
}
export const roomComparator = (url: string) => (room: string) =>
displayChannel(url, room).toLowerCase()
// User stuff
export const userSettings = withGetter(
@@ -633,6 +636,20 @@ export const userMembership = withGetter(
}),
)
export const deriveUserRooms = (url: string) =>
derived(userMembership, $userMembership => [
GENERAL,
...sortBy(roomComparator(url), getMembershipRoomsByUrl(url, $userMembership)),
])
export const deriveOtherRooms = (url: string) =>
derived([deriveUserRooms(url), channelsByUrl], ([$userRooms, $channelsByUrl]) =>
sortBy(
roomComparator(url),
($channelsByUrl.get(url) || []).filter(c => !$userRooms.includes(c.room)).map(c => c.room),
),
)
// Other utils
export const encodeRelay = (url: string) => encodeURIComponent(normalizeRelayUrl(url))