Make voice rooms in sidebar reactive
This commit is contained in:
@@ -47,6 +47,8 @@
|
|||||||
deriveSpaceMembers,
|
deriveSpaceMembers,
|
||||||
deriveUserRooms,
|
deriveUserRooms,
|
||||||
deriveOtherRooms,
|
deriveOtherRooms,
|
||||||
|
deriveRoomsWithLivekit,
|
||||||
|
deriveRoomsNoText,
|
||||||
userSpaceUrls,
|
userSpaceUrls,
|
||||||
hasNip29,
|
hasNip29,
|
||||||
deriveUserCanCreateRoom,
|
deriveUserCanCreateRoom,
|
||||||
@@ -55,8 +57,6 @@
|
|||||||
notificationSettings,
|
notificationSettings,
|
||||||
deriveShouldNotify,
|
deriveShouldNotify,
|
||||||
displayRoom,
|
displayRoom,
|
||||||
roomHasLivekit,
|
|
||||||
roomIsNoText,
|
|
||||||
} from "@app/core/state"
|
} from "@app/core/state"
|
||||||
import {setSpaceNotifications} from "@app/core/commands"
|
import {setSpaceNotifications} from "@app/core/commands"
|
||||||
import {pushModal} from "@app/util/modal"
|
import {pushModal} from "@app/util/modal"
|
||||||
@@ -72,6 +72,8 @@
|
|||||||
const calendarPath = makeSpacePath(url, "calendar")
|
const calendarPath = makeSpacePath(url, "calendar")
|
||||||
const userRooms = deriveUserRooms(url)
|
const userRooms = deriveUserRooms(url)
|
||||||
const otherRooms = deriveOtherRooms(url)
|
const otherRooms = deriveOtherRooms(url)
|
||||||
|
const roomsWithLivekit = deriveRoomsWithLivekit(url)
|
||||||
|
const roomsNoText = deriveRoomsNoText(url)
|
||||||
const members = deriveSpaceMembers(url)
|
const members = deriveSpaceMembers(url)
|
||||||
const userIsAdmin = deriveUserIsSpaceAdmin(url)
|
const userIsAdmin = deriveUserIsSpaceAdmin(url)
|
||||||
const reports = deriveEventsForUrl(url, [{kinds: [REPORT]}])
|
const reports = deriveEventsForUrl(url, [{kinds: [REPORT]}])
|
||||||
@@ -260,10 +262,10 @@
|
|||||||
<SecondaryNavHeader>Your Rooms</SecondaryNavHeader>
|
<SecondaryNavHeader>Your Rooms</SecondaryNavHeader>
|
||||||
{/if}
|
{/if}
|
||||||
{#each $userRooms as h (h)}
|
{#each $userRooms as h (h)}
|
||||||
{#if !roomIsNoText(url, h)}
|
{#if !$roomsNoText.has(h)}
|
||||||
<SpaceMenuRoomItem notify {replaceState} {url} {h} />
|
<SpaceMenuRoomItem notify {replaceState} {url} {h} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if roomHasLivekit(url, h)}
|
{#if $roomsWithLivekit.has(h)}
|
||||||
<VoiceRoomItem {url} {h} />
|
<VoiceRoomItem {url} {h} />
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
@@ -284,10 +286,10 @@
|
|||||||
</label>
|
</label>
|
||||||
{/if}
|
{/if}
|
||||||
{#each $roomSearch.searchValues(term) as h (h)}
|
{#each $roomSearch.searchValues(term) as h (h)}
|
||||||
{#if !roomIsNoText(url, h)}
|
{#if !$roomsNoText.has(h)}
|
||||||
<SpaceMenuRoomItem {replaceState} {url} {h} />
|
<SpaceMenuRoomItem {replaceState} {url} {h} />
|
||||||
{/if}
|
{/if}
|
||||||
{#if roomHasLivekit(url, h)}
|
{#if $roomsWithLivekit.has(h)}
|
||||||
<VoiceRoomItem {url} {h} />
|
<VoiceRoomItem {url} {h} />
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -663,6 +663,28 @@ export const displayRoom = (url: string, h: string) => getRoom(makeRoomId(url, h
|
|||||||
|
|
||||||
export const roomComparator = (url: string) => (h: string) => displayRoom(url, h).toLowerCase()
|
export const roomComparator = (url: string) => (h: string) => displayRoom(url, h).toLowerCase()
|
||||||
|
|
||||||
|
export const deriveRoomsWithLivekit = (url: string) =>
|
||||||
|
derived(roomsById, $roomsById => {
|
||||||
|
const set = new Set<string>()
|
||||||
|
for (const room of $roomsById.values()) {
|
||||||
|
if (room.url === url && room.event?.tags?.some(t => t[0] === "livekit")) {
|
||||||
|
set.add(room.h)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set
|
||||||
|
})
|
||||||
|
|
||||||
|
export const deriveRoomsNoText = (url: string) =>
|
||||||
|
derived(roomsById, $roomsById => {
|
||||||
|
const set = new Set<string>()
|
||||||
|
for (const room of $roomsById.values()) {
|
||||||
|
if (room.url === url && room.event?.tags?.some(t => t[0] === "no-text")) {
|
||||||
|
set.add(room.h)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return set
|
||||||
|
})
|
||||||
|
|
||||||
export const roomHasLivekit = (url: string, h: string) => {
|
export const roomHasLivekit = (url: string, h: string) => {
|
||||||
const room = getRoom(makeRoomId(url, h))
|
const room = getRoom(makeRoomId(url, h))
|
||||||
return room?.event?.tags?.some(t => t[0] === "livekit") ?? false
|
return room?.event?.tags?.some(t => t[0] === "livekit") ?? false
|
||||||
|
|||||||
Reference in New Issue
Block a user