Fix image modal, only show + room if the user is allowed

This commit is contained in:
Jon Staab
2025-11-13 10:32:37 -08:00
parent 8e2ebd11fc
commit cc4c7b5fe9
3 changed files with 14 additions and 5 deletions

View File

@@ -34,6 +34,7 @@
target: element, target: element,
props: { props: {
onClose: closeModals, onClose: closeModals,
fullscreen: options.fullscreen,
children: createRawSnippet(() => ({ children: createRawSnippet(() => ({
render: () => "<div></div>", render: () => "<div></div>",
setup: (target: Element) => { setup: (target: Element) => {

View File

@@ -882,11 +882,19 @@ export const deriveUserRoomMembershipStatus = (url: string, h: string) =>
export const deriveUserCanCreateRoom = (url: string) => export const deriveUserCanCreateRoom = (url: string) =>
derived( derived(
[pubkey, deriveEventsForUrl(url, [{kinds: [ROOM_CREATE_PERMISSION]}])], [
([$pubkey, $events]) => { pubkey,
const event = first($events) deriveEventsForUrl(url, [{kinds: [ROOM_CREATE_PERMISSION]}]),
deriveUserIsSpaceAdmin(url),
],
([$pubkey, $events, $isAdmin]) => {
for (const event of $events) {
if (getPubkeyTagValues(event.tags).includes($pubkey!)) {
return true
}
}
return event ? getPubkeyTagValues(event.tags).includes($pubkey!) : true return $isAdmin
}, },
) )

View File

@@ -28,7 +28,7 @@
transition:fade={{duration: 300}} transition:fade={{duration: 300}}
onclick={onClose}> onclick={onClose}>
</button> </button>
<div class="scroll-container {extraClass}" transition:fly={{duration: 300}}> <div class="scroll-container relative {extraClass}" transition:fly={{duration: 300}}>
{@render children?.()} {@render children?.()}
</div> </div>
</div> </div>