refac: $user

This commit is contained in:
Timothy Jaeryang Baek
2025-03-31 20:32:12 -07:00
parent 1b7c125f00
commit e0ec2cdeb0
27 changed files with 57 additions and 57 deletions

View File

@@ -167,7 +167,7 @@
{#if $user !== undefined}
<UserMenu
className="max-w-[200px]"
role={$user.role}
role={$user?.role}
on:show={(e) => {
if (e.detail === 'archived-chat') {
showArchivedChats.set(true);
@@ -180,7 +180,7 @@
>
<div class=" self-center">
<img
src={$user.profile_image_url}
src={$user?.profile_image_url}
class="size-6 object-cover rounded-full"
alt="User profile"
draggable="false"

View File

@@ -446,7 +446,7 @@
});
if (res) {
$socket.emit('join-channels', { auth: { token: $user.token } });
$socket.emit('join-channels', { auth: { token: $user?.token } });
await initChannels();
showCreateChannel = false;
}
@@ -627,13 +627,13 @@
? 'opacity-20'
: ''}"
>
{#if $config?.features?.enable_channels && ($user.role === 'admin' || $channels.length > 0) && !search}
{#if $config?.features?.enable_channels && ($user?.role === 'admin' || $channels.length > 0) && !search}
<Folder
className="px-2 mt-0.5"
name={$i18n.t('Channels')}
dragAndDrop={false}
onAdd={async () => {
if ($user.role === 'admin') {
if ($user?.role === 'admin') {
await tick();
setTimeout(() => {
@@ -891,9 +891,9 @@
<div class="px-2">
<div class="flex flex-col font-primary">
{#if $user !== undefined}
{#if $user !== undefined && $user !== null}
<UserMenu
role={$user.role}
role={$user?.role}
on:show={(e) => {
if (e.detail === 'archived-chat') {
showArchivedChats.set(true);
@@ -908,12 +908,12 @@
>
<div class=" self-center mr-3">
<img
src={$user.profile_image_url}
src={$user?.profile_image_url}
class=" max-w-[30px] object-cover rounded-full"
alt="User profile"
/>
</div>
<div class=" self-center font-medium">{$user.name}</div>
<div class=" self-center font-medium">{$user?.name}</div>
</button>
</UserMenu>
{/if}