Disable create room button if no permission

This commit is contained in:
Matthew Remmel
2025-10-13 12:53:25 -04:00
committed by Jon Staab
parent 5b22d6ac01
commit a39a87ba6d
2 changed files with 20 additions and 2 deletions
+12
View File
@@ -22,6 +22,7 @@ import {
groupBy,
always,
tryCatch,
last,
} from "@welshman/lib"
import type {Socket} from "@welshman/net"
import {Pool, load, AuthStateEvent, AuthStatus, SocketEvent, netContext} from "@welshman/net"
@@ -760,6 +761,17 @@ export const deriveUserMembershipStatus = (url: string, room: string) =>
},
)
export const deriveUserCanCreateRoom = (url: string) =>
derived([pubkey, deriveEventsForUrl(url, [{kinds: [39004]}])], ([$pubkey, $events]) => {
const latest = last($events)
if (!latest) {
return true
}
return getTagValues("p", latest.tags).includes($pubkey!)
})
// Other utils
export const encodeRelay = (url: string) =>