forked from coracle/flotilla
Add relay members list and room join/leave events
This commit is contained in:
@@ -17,9 +17,11 @@ import {
|
||||
chats,
|
||||
hasNip29,
|
||||
getUrlsForEvent,
|
||||
userRoomsByUrl,
|
||||
repositoryStore,
|
||||
userSettingsValues,
|
||||
userGroupSelections,
|
||||
getSpaceUrlsFromGroupSelections,
|
||||
getSpaceRoomsFromGroupSelections,
|
||||
} from "@app/core/state"
|
||||
import {preferencesStorageProvider} from "@src/lib/storage"
|
||||
import {Badge} from "@capawesome/capacitor-badge"
|
||||
@@ -42,11 +44,19 @@ export const notifications = derived(
|
||||
throttled(
|
||||
1000,
|
||||
derived(
|
||||
[pubkey, checked, chats, userRoomsByUrl, repositoryStore, getUrlsForEvent, relaysByUrl],
|
||||
[pubkey, checked, chats, userGroupSelections, repositoryStore, getUrlsForEvent, relaysByUrl],
|
||||
identity,
|
||||
),
|
||||
),
|
||||
([$pubkey, $checked, $chats, $userRoomsByUrl, $repository, $getUrlsForEvent, $relaysByUrl]) => {
|
||||
([
|
||||
$pubkey,
|
||||
$checked,
|
||||
$chats,
|
||||
$userGroupSelections,
|
||||
$repository,
|
||||
$getUrlsForEvent,
|
||||
$relaysByUrl,
|
||||
]) => {
|
||||
const hasNotification = (path: string, latestEvent: TrustedEvent | undefined) => {
|
||||
if (!latestEvent || latestEvent.pubkey === $pubkey) {
|
||||
return false
|
||||
@@ -85,7 +95,7 @@ export const notifications = derived(
|
||||
|
||||
const allMessages = $repository.query([{kinds: [MESSAGE, THREAD, ZAP_GOAL, EVENT_TIME]}])
|
||||
|
||||
for (const [url, rooms] of $userRoomsByUrl.entries()) {
|
||||
for (const url of getSpaceUrlsFromGroupSelections($userGroupSelections)) {
|
||||
const spacePath = makeSpacePath(url)
|
||||
const spacePathMobile = spacePath + ":mobile"
|
||||
const goalPath = makeGoalPath(url)
|
||||
@@ -161,7 +171,7 @@ export const notifications = derived(
|
||||
}
|
||||
|
||||
if (hasNip29($relaysByUrl.get(url))) {
|
||||
for (const room of rooms) {
|
||||
for (const room of getSpaceRoomsFromGroupSelections(url, $userGroupSelections)) {
|
||||
const roomPath = makeRoomPath(url, room)
|
||||
const latestEvent = allMessages.find(
|
||||
e => $getUrlsForEvent(e.id).includes(url) && e.tags.find(spec(["h", room])),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type {Page} from "@sveltejs/kit"
|
||||
import {get} from "svelte/store"
|
||||
import * as nip19 from "nostr-tools/nip19"
|
||||
import {goto} from "$app/navigation"
|
||||
import {nthEq, sleep} from "@welshman/lib"
|
||||
@@ -21,7 +22,7 @@ import {
|
||||
entityLink,
|
||||
decodeRelay,
|
||||
encodeRelay,
|
||||
userRoomsByUrl,
|
||||
userSpaceUrls,
|
||||
hasNip29,
|
||||
ROOM,
|
||||
} from "@app/core/state"
|
||||
@@ -66,7 +67,7 @@ export const makeCalendarPath = (url: string, eventId?: string) =>
|
||||
export const getPrimaryNavItem = ($page: Page) => $page.route?.id?.split("/")[1]
|
||||
|
||||
export const getPrimaryNavItemIndex = ($page: Page) => {
|
||||
const urls = Array.from(userRoomsByUrl.get().keys())
|
||||
const urls = get(userSpaceUrls)
|
||||
|
||||
switch (getPrimaryNavItem($page)) {
|
||||
case "discover":
|
||||
|
||||
Reference in New Issue
Block a user