Skip to content

Commit

Permalink
add permission check
Browse files Browse the repository at this point in the history
  • Loading branch information
jay3332 committed Jul 10, 2024
1 parent 6d45b27 commit fd948b7
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/pages/guilds/GuildHome.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {createMemo} from "solid-js";
import {createMemo, Show} from "solid-js";
import {A, useParams} from "@solidjs/router";
import {getApi} from "../../api/Api";
import NotFound from "../NotFound";
Expand All @@ -19,6 +19,8 @@ export default function GuildHome() {
if (!guild())
return <NotFound />

const permissions = createMemo(() => api.cache!.getClientPermissions(guild().id))

const onlineCount = createMemo(() => api.cache!.memberReactor
.get(guild().id)!
.reduce((acc, next) => api.cache!.presences.get(next)?.status === 'offline' ? acc : acc + 1, 0)
Expand Down Expand Up @@ -73,14 +75,16 @@ export default function GuildHome() {
</div>
</div>
<div class="gap-x-2 z-[1]">
<div use:tooltip="Settings">
<A
href={`/guilds/${guild().id}/settings`}
class="flex aspect-square items-center justify-center p-3 bg-bg-3/70 rounded-full"
>
<Icon icon={Gear} class="fill-fg w-5 h-5" />
</A>
</div>
<Show when={permissions().has('MANAGE_GUILD')}>
<div use:tooltip="Settings">
<A
href={`/guilds/${guild().id}/settings`}
class="flex aspect-square items-center justify-center p-3 bg-bg-3/70 rounded-full"
>
<Icon icon={Gear} class="fill-fg w-5 h-5" />
</A>
</div>
</Show>
</div>
</div>
</div>
Expand Down

0 comments on commit fd948b7

Please sign in to comment.