frontend: hide edit buttons for channels and messages if the user can't edit them

This commit is contained in:
hippoz 2022-04-27 20:24:50 +03:00
parent 21b06c38d2
commit fb9fccb038
No known key found for this signature in database
GPG key ID: 7C52899193467641
2 changed files with 12 additions and 8 deletions

View file

@ -1,6 +1,6 @@
<script>
import { MoreVerticalIcon } from "svelte-feather-icons";
import { overlayStore } from "../stores";
import { overlayStore, userInfoStore } from "../stores";
export let message;
</script>
@ -49,7 +49,9 @@
<div class="message">
<span class="author">{ message.author_username }</span>
<span class="message-content" class:pending={ message._isPending }>{ message.content }</span>
<button class="icon-button icon-button-auto edit-message" on:click="{ () => overlayStore.open('editMessage', { message }) }">
<MoreVerticalIcon />
</button>
{#if $userInfoStore && message.author_id === $userInfoStore.id}
<button class="icon-button icon-button-auto edit-message" on:click="{ () => overlayStore.open('editMessage', { message }) }">
<MoreVerticalIcon />
</button>
{/if}
</div>

View file

@ -2,7 +2,7 @@
import { HashIcon, PlusIcon, MoreVerticalIcon } from "svelte-feather-icons";
import { quadInOut } from "svelte/easing";
import { fly } from "svelte/transition";
import { channels, overlayStore, selectedChannel, showChannelView, showSidebar, smallViewport } from "../stores";
import { channels, overlayStore, selectedChannel, showChannelView, showSidebar, smallViewport, userInfoStore } from "../stores";
import UserTopBar from "./UserTopBar.svelte";
let pendingSelectChannel = null;
@ -40,9 +40,11 @@
<HashIcon />
</div>
<span>{ channel.name }</span>
<button class="icon-button icon-button-auto" on:click|stopPropagation="{ () => overlayStore.open('editChannel', { channel }) }">
<MoreVerticalIcon />
</button>
{#if $userInfoStore && channel.owner_id === $userInfoStore.id}
<button class="icon-button icon-button-auto" on:click|stopPropagation="{ () => overlayStore.open('editChannel', { channel }) }">
<MoreVerticalIcon />
</button>
{/if}
</button>
{/each}
<button on:click="{ () => overlayStore.open('createChannel') }" class="sidebar-button">