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
Signed by: hippoz
GPG key ID: 7C52899193467641
2 changed files with 12 additions and 8 deletions

View file

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

View file

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