enh: update channel

This commit is contained in:
Timothy Jaeryang Baek
2024-12-22 23:09:51 -07:00
parent e9194d9524
commit 7ad8918cd9
9 changed files with 192 additions and 35 deletions
+21 -5
View File
@@ -53,7 +53,7 @@
import Tooltip from '../common/Tooltip.svelte';
import Folders from './Sidebar/Folders.svelte';
import { getChannels, createNewChannel } from '$lib/apis/channels';
import CreateChannelModal from './Sidebar/CreateChannelModal.svelte';
import ChannelModal from './Sidebar/ChannelModal.svelte';
import ChannelItem from './Sidebar/ChannelItem.svelte';
import PencilSquare from '../icons/PencilSquare.svelte';
@@ -403,10 +403,21 @@
}}
/>
<CreateChannelModal
<ChannelModal
bind:show={showCreateChannel}
onChange={async () => {
await initChannels();
onSubmit={async ({ name, access_control }) => {
const res = await createNewChannel(localStorage.token, {
name: name,
access_control: access_control
}).catch((error) => {
toast.error(error);
return null;
});
if (res) {
await initChannels();
showCreateChannel = false;
}
}}
/>
@@ -642,7 +653,12 @@
onAddLabel={$i18n.t('Create Channel')}
>
{#each $channels as channel}
<ChannelItem id={channel.id} name={channel.name} />
<ChannelItem
{channel}
onUpdate={async () => {
await initChannels();
}}
/>
{/each}
</Folder>
{/if}