Disable create room button if no permission
This commit is contained in:
committed by
Jon Staab
parent
5b22d6ac01
commit
a39a87ba6d
@@ -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) =>
|
||||
|
||||
Reference in New Issue
Block a user