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

@@ -55,9 +55,9 @@
let version;
onMount(async () => {
if ($user === undefined) {
if ($user === undefined || $user === null) {
await goto('/auth');
} else if (['user', 'admin'].includes($user.role)) {
} else if (['user', 'admin'].includes($user?.role)) {
try {
// Check if IndexedDB exists
DB = await openDB('Chats', 1);
@@ -191,7 +191,7 @@
}
});
if ($user.role === 'admin' && ($settings?.showChangelog ?? true)) {
if ($user?.role === 'admin' && ($settings?.showChangelog ?? true)) {
showChangelog.set($settings?.version !== $config.version);
}
@@ -199,14 +199,14 @@
temporaryChatEnabled.set(true);
}
console.log($user.permissions);
console.log($user?.permissions);
if ($user?.permissions?.chat?.temporary_enforced) {
temporaryChatEnabled.set(true);
}
// Check for version updates
if ($user.role === 'admin') {
if ($user?.role === 'admin') {
// Check if the user has dismissed the update toast in the last 24 hours
if (localStorage.dismissedUpdateToast) {
const dismissedUpdateToast = new Date(Number(localStorage.dismissedUpdateToast));
@@ -255,7 +255,7 @@
class=" text-gray-700 dark:text-gray-100 bg-white dark:bg-gray-900 h-screen max-h-[100dvh] overflow-auto flex flex-row justify-end"
>
{#if loaded}
{#if !['user', 'admin'].includes($user.role)}
{#if !['user', 'admin'].includes($user?.role)}
<AccountPending />
{:else if localDBChats.length > 0}
<div class="fixed w-full h-full flex z-50">