mirror of
https://github.com/open-webui/open-webui
synced 2025-06-26 18:26:48 +00:00
refac: $user
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user