mirror of
https://github.com/open-webui/open-webui
synced 2025-05-24 06:44:24 +00:00
refac: $user
This commit is contained in:
parent
1b7c125f00
commit
e0ec2cdeb0
@ -136,7 +136,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if ($user.role === 'admin') {
|
if ($user?.role === 'admin') {
|
||||||
let ollamaConfig = {};
|
let ollamaConfig = {};
|
||||||
let openaiConfig = {};
|
let openaiConfig = {};
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if ($user.role === 'admin') {
|
if ($user?.role === 'admin') {
|
||||||
evaluationConfig = await getConfig(localStorage.token).catch((err) => {
|
evaluationConfig = await getConfig(localStorage.token).catch((err) => {
|
||||||
toast.error(err);
|
toast.error(err);
|
||||||
return null;
|
return null;
|
||||||
|
@ -176,7 +176,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if ($user.role === 'admin') {
|
if ($user?.role === 'admin') {
|
||||||
const res = await getConfig(localStorage.token).catch((error) => {
|
const res = await getConfig(localStorage.token).catch((error) => {
|
||||||
toast.error(`${error}`);
|
toast.error(`${error}`);
|
||||||
return null;
|
return null;
|
||||||
|
@ -380,7 +380,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if $user.role === 'admin'}
|
{#if $user?.role === 'admin'}
|
||||||
<div class=" space-y-3">
|
<div class=" space-y-3">
|
||||||
<div class="flex w-full justify-between mb-2">
|
<div class="flex w-full justify-between mb-2">
|
||||||
<div class=" self-center text-sm font-semibold">
|
<div class=" self-center text-sm font-semibold">
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
let ollamaConfig = null;
|
let ollamaConfig = null;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if ($user.role === 'admin') {
|
if ($user?.role === 'admin') {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
(async () => {
|
(async () => {
|
||||||
ollamaConfig = await getOllamaConfig(localStorage.token);
|
ollamaConfig = await getOllamaConfig(localStorage.token);
|
||||||
|
@ -106,7 +106,7 @@
|
|||||||
messages[idx] = data;
|
messages[idx] = data;
|
||||||
}
|
}
|
||||||
} else if (type === 'typing' && event.message_id === null) {
|
} else if (type === 'typing' && event.message_id === null) {
|
||||||
if (event.user.id === $user.id) {
|
if (event.user.id === $user?.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@
|
|||||||
if (
|
if (
|
||||||
(message?.reactions ?? [])
|
(message?.reactions ?? [])
|
||||||
.find((reaction) => reaction.name === name)
|
.find((reaction) => reaction.name === name)
|
||||||
?.user_ids?.includes($user.id) ??
|
?.user_ids?.includes($user?.id) ??
|
||||||
false
|
false
|
||||||
) {
|
) {
|
||||||
messages = messages.map((m) => {
|
messages = messages.map((m) => {
|
||||||
@ -140,7 +140,7 @@
|
|||||||
const reaction = m.reactions.find((reaction) => reaction.name === name);
|
const reaction = m.reactions.find((reaction) => reaction.name === name);
|
||||||
|
|
||||||
if (reaction) {
|
if (reaction) {
|
||||||
reaction.user_ids = reaction.user_ids.filter((id) => id !== $user.id);
|
reaction.user_ids = reaction.user_ids.filter((id) => id !== $user?.id);
|
||||||
reaction.count = reaction.user_ids.length;
|
reaction.count = reaction.user_ids.length;
|
||||||
|
|
||||||
if (reaction.count === 0) {
|
if (reaction.count === 0) {
|
||||||
@ -167,12 +167,12 @@
|
|||||||
const reaction = m.reactions.find((reaction) => reaction.name === name);
|
const reaction = m.reactions.find((reaction) => reaction.name === name);
|
||||||
|
|
||||||
if (reaction) {
|
if (reaction) {
|
||||||
reaction.user_ids.push($user.id);
|
reaction.user_ids.push($user?.id);
|
||||||
reaction.count = reaction.user_ids.length;
|
reaction.count = reaction.user_ids.length;
|
||||||
} else {
|
} else {
|
||||||
m.reactions.push({
|
m.reactions.push({
|
||||||
name: name,
|
name: name,
|
||||||
user_ids: [$user.id],
|
user_ids: [$user?.id],
|
||||||
count: 1
|
count: 1
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if message.user_id === $user.id || $user.role === 'admin'}
|
{#if message.user_id === $user?.id || $user?.role === 'admin'}
|
||||||
<Tooltip content={$i18n.t('Edit')}>
|
<Tooltip content={$i18n.t('Edit')}>
|
||||||
<button
|
<button
|
||||||
class="hover:bg-gray-100 dark:hover:bg-gray-800 transition rounded-lg p-1"
|
class="hover:bg-gray-100 dark:hover:bg-gray-800 transition rounded-lg p-1"
|
||||||
@ -265,7 +265,7 @@
|
|||||||
<Tooltip content={`:${reaction.name}:`}>
|
<Tooltip content={`:${reaction.name}:`}>
|
||||||
<button
|
<button
|
||||||
class="flex items-center gap-1.5 transition rounded-xl px-2 py-1 cursor-pointer {reaction.user_ids.includes(
|
class="flex items-center gap-1.5 transition rounded-xl px-2 py-1 cursor-pointer {reaction.user_ids.includes(
|
||||||
$user.id
|
$user?.id
|
||||||
)
|
)
|
||||||
? ' bg-blue-300/10 outline outline-blue-500/50 outline-1'
|
? ' bg-blue-300/10 outline outline-blue-500/50 outline-1'
|
||||||
: 'bg-gray-300/10 dark:bg-gray-500/10 hover:outline hover:outline-gray-700/30 dark:hover:outline-gray-300/30 hover:outline-1'}"
|
: 'bg-gray-300/10 dark:bg-gray-500/10 hover:outline hover:outline-gray-700/30 dark:hover:outline-gray-300/30 hover:outline-1'}"
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
{#if $user !== undefined}
|
{#if $user !== undefined}
|
||||||
<UserMenu
|
<UserMenu
|
||||||
className="max-w-[200px]"
|
className="max-w-[200px]"
|
||||||
role={$user.role}
|
role={$user?.role}
|
||||||
on:show={(e) => {
|
on:show={(e) => {
|
||||||
if (e.detail === 'archived-chat') {
|
if (e.detail === 'archived-chat') {
|
||||||
showArchivedChats.set(true);
|
showArchivedChats.set(true);
|
||||||
@ -71,7 +71,7 @@
|
|||||||
>
|
>
|
||||||
<div class=" self-center">
|
<div class=" self-center">
|
||||||
<img
|
<img
|
||||||
src={$user.profile_image_url}
|
src={$user?.profile_image_url}
|
||||||
class="size-6 object-cover rounded-full"
|
class="size-6 object-cover rounded-full"
|
||||||
alt="User profile"
|
alt="User profile"
|
||||||
draggable="false"
|
draggable="false"
|
||||||
|
@ -89,7 +89,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (type === 'typing' && event.message_id === threadId) {
|
} else if (type === 'typing' && event.message_id === threadId) {
|
||||||
if (event.user.id === $user.id) {
|
if (event.user.id === $user?.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1498,7 +1498,7 @@
|
|||||||
role: 'system',
|
role: 'system',
|
||||||
content: `${promptTemplate(
|
content: `${promptTemplate(
|
||||||
params?.system ?? $settings?.system ?? '',
|
params?.system ?? $settings?.system ?? '',
|
||||||
$user.name,
|
$user?.name,
|
||||||
$settings?.userLocation
|
$settings?.userLocation
|
||||||
? await getAndUpdateUserLocation(localStorage.token).catch((err) => {
|
? await getAndUpdateUserLocation(localStorage.token).catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@ -1572,23 +1572,23 @@
|
|||||||
features: {
|
features: {
|
||||||
image_generation:
|
image_generation:
|
||||||
$config?.features?.enable_image_generation &&
|
$config?.features?.enable_image_generation &&
|
||||||
($user.role === 'admin' || $user?.permissions?.features?.image_generation)
|
($user?.role === 'admin' || $user?.permissions?.features?.image_generation)
|
||||||
? imageGenerationEnabled
|
? imageGenerationEnabled
|
||||||
: false,
|
: false,
|
||||||
code_interpreter:
|
code_interpreter:
|
||||||
$config?.features?.enable_code_interpreter &&
|
$config?.features?.enable_code_interpreter &&
|
||||||
($user.role === 'admin' || $user?.permissions?.features?.code_interpreter)
|
($user?.role === 'admin' || $user?.permissions?.features?.code_interpreter)
|
||||||
? codeInterpreterEnabled
|
? codeInterpreterEnabled
|
||||||
: false,
|
: false,
|
||||||
web_search:
|
web_search:
|
||||||
$config?.features?.enable_web_search &&
|
$config?.features?.enable_web_search &&
|
||||||
($user.role === 'admin' || $user?.permissions?.features?.web_search)
|
($user?.role === 'admin' || $user?.permissions?.features?.web_search)
|
||||||
? webSearchEnabled || ($settings?.webSearch ?? false) === 'always'
|
? webSearchEnabled || ($settings?.webSearch ?? false) === 'always'
|
||||||
: false
|
: false
|
||||||
},
|
},
|
||||||
variables: {
|
variables: {
|
||||||
...getPromptVariables(
|
...getPromptVariables(
|
||||||
$user.name,
|
$user?.name,
|
||||||
$settings?.userLocation
|
$settings?.userLocation
|
||||||
? await getAndUpdateUserLocation(localStorage.token).catch((err) => {
|
? await getAndUpdateUserLocation(localStorage.token).catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
{#if models[selectedModelIdx]?.name}
|
{#if models[selectedModelIdx]?.name}
|
||||||
{models[selectedModelIdx]?.name}
|
{models[selectedModelIdx]?.name}
|
||||||
{:else}
|
{:else}
|
||||||
{$i18n.t('Hello, {{name}}', { name: $user.name })}
|
{$i18n.t('Hello, {{name}}', { name: $user?.name })}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</Collapsible>
|
</Collapsible>
|
||||||
|
|
||||||
{#if $user.role === 'admin' || $user?.permissions.chat?.controls}
|
{#if $user?.role === 'admin' || $user?.permissions.chat?.controls}
|
||||||
<hr class="my-2 border-gray-50 dark:border-gray-700/10" />
|
<hr class="my-2 border-gray-50 dark:border-gray-700/10" />
|
||||||
|
|
||||||
<Collapsible title={$i18n.t('System Prompt')} open={true} buttonClassName="w-full">
|
<Collapsible title={$i18n.t('System Prompt')} open={true} buttonClassName="w-full">
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
|
|
||||||
if (command.content.includes('{{USER_NAME}}')) {
|
if (command.content.includes('{{USER_NAME}}')) {
|
||||||
console.log($user);
|
console.log($user);
|
||||||
const name = $user.name || 'User';
|
const name = $user?.name || 'User';
|
||||||
text = text.replaceAll('{{USER_NAME}}', name);
|
text = text.replaceAll('{{USER_NAME}}', name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
let fileUploadEnabled = true;
|
let fileUploadEnabled = true;
|
||||||
$: fileUploadEnabled = $user.role === 'admin' || $user?.permissions?.chat?.file_upload;
|
$: fileUploadEnabled = $user?.role === 'admin' || $user?.permissions?.chat?.file_upload;
|
||||||
|
|
||||||
const init = async () => {
|
const init = async () => {
|
||||||
if ($_tools === null) {
|
if ($_tools === null) {
|
||||||
|
@ -920,7 +920,7 @@
|
|||||||
|
|
||||||
{#if message.done}
|
{#if message.done}
|
||||||
{#if !readOnly}
|
{#if !readOnly}
|
||||||
{#if $user.role === 'user' ? ($user?.permissions?.chat?.edit ?? true) : true}
|
{#if $user?.role === 'user' ? ($user?.permissions?.chat?.edit ?? true) : true}
|
||||||
<Tooltip content={$i18n.t('Edit')} placement="bottom">
|
<Tooltip content={$i18n.t('Edit')} placement="bottom">
|
||||||
<button
|
<button
|
||||||
class="{isLastMessage
|
class="{isLastMessage
|
||||||
@ -1053,7 +1053,7 @@
|
|||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
{#if $config?.features.enable_image_generation && ($user.role === 'admin' || $user?.permissions?.features?.image_generation) && !readOnly}
|
{#if $config?.features.enable_image_generation && ($user?.role === 'admin' || $user?.permissions?.features?.image_generation) && !readOnly}
|
||||||
<Tooltip content={$i18n.t('Generate Image')} placement="bottom">
|
<Tooltip content={$i18n.t('Generate Image')} placement="bottom">
|
||||||
<button
|
<button
|
||||||
class="{isLastMessage
|
class="{isLastMessage
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
label: model.name,
|
label: model.name,
|
||||||
model: model
|
model: model
|
||||||
}))}
|
}))}
|
||||||
showTemporaryChatControl={$user.role === 'user'
|
showTemporaryChatControl={$user?.role === 'user'
|
||||||
? ($user?.permissions?.chat?.temporary ?? true) &&
|
? ($user?.permissions?.chat?.temporary ?? true) &&
|
||||||
!($user?.permissions?.chat?.temporary_enforced ?? false)
|
!($user?.permissions?.chat?.temporary_enforced ?? false)
|
||||||
: true}
|
: true}
|
||||||
|
@ -634,7 +634,7 @@
|
|||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
|
||||||
{#if !(searchValue.trim() in $MODEL_DOWNLOAD_POOL) && searchValue && ollamaVersion && $user.role === 'admin'}
|
{#if !(searchValue.trim() in $MODEL_DOWNLOAD_POOL) && searchValue && ollamaVersion && $user?.role === 'admin'}
|
||||||
<Tooltip
|
<Tooltip
|
||||||
content={$i18n.t(`Pull "{{searchValue}}" from Ollama.com`, {
|
content={$i18n.t(`Pull "{{searchValue}}" from Ollama.com`, {
|
||||||
searchValue: searchValue
|
searchValue: searchValue
|
||||||
|
@ -147,10 +147,10 @@
|
|||||||
</button>
|
</button>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
{#if $user !== undefined}
|
{#if $user !== undefined && $user !== null}
|
||||||
<UserMenu
|
<UserMenu
|
||||||
className="max-w-[200px]"
|
className="max-w-[200px]"
|
||||||
role={$user.role}
|
role={$user?.role}
|
||||||
on:show={(e) => {
|
on:show={(e) => {
|
||||||
if (e.detail === 'archived-chat') {
|
if (e.detail === 'archived-chat') {
|
||||||
showArchivedChats.set(true);
|
showArchivedChats.set(true);
|
||||||
@ -163,7 +163,7 @@
|
|||||||
>
|
>
|
||||||
<div class=" self-center">
|
<div class=" self-center">
|
||||||
<img
|
<img
|
||||||
src={$user.profile_image_url}
|
src={$user?.profile_image_url}
|
||||||
class="size-6 object-cover rounded-full"
|
class="size-6 object-cover rounded-full"
|
||||||
alt="User profile"
|
alt="User profile"
|
||||||
draggable="false"
|
draggable="false"
|
||||||
|
@ -142,7 +142,7 @@
|
|||||||
{#if models[selectedModelIdx]?.name}
|
{#if models[selectedModelIdx]?.name}
|
||||||
{models[selectedModelIdx]?.name}
|
{models[selectedModelIdx]?.name}
|
||||||
{:else}
|
{:else}
|
||||||
{$i18n.t('Hello, {{name}}', { name: $user.name })}
|
{$i18n.t('Hello, {{name}}', { name: $user?.name })}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -31,8 +31,8 @@
|
|||||||
let profileImageInputElement: HTMLInputElement;
|
let profileImageInputElement: HTMLInputElement;
|
||||||
|
|
||||||
const submitHandler = async () => {
|
const submitHandler = async () => {
|
||||||
if (name !== $user.name) {
|
if (name !== $user?.name) {
|
||||||
if (profileImageUrl === generateInitialsImage($user.name) || profileImageUrl === '') {
|
if (profileImageUrl === generateInitialsImage($user?.name) || profileImageUrl === '') {
|
||||||
profileImageUrl = generateInitialsImage(name);
|
profileImageUrl = generateInitialsImage(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,8 +75,8 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
name = $user.name;
|
name = $user?.name;
|
||||||
profileImageUrl = $user.profile_image_url;
|
profileImageUrl = $user?.profile_image_url;
|
||||||
webhookUrl = $settings?.notifications?.webhook_url ?? '';
|
webhookUrl = $settings?.notifications?.webhook_url ?? '';
|
||||||
|
|
||||||
APIKey = await getAPIKey(localStorage.token).catch((error) => {
|
APIKey = await getAPIKey(localStorage.token).catch((error) => {
|
||||||
@ -214,7 +214,7 @@
|
|||||||
<button
|
<button
|
||||||
class=" text-xs text-center text-gray-800 dark:text-gray-400 rounded-full px-4 py-0.5 bg-gray-100 dark:bg-gray-850"
|
class=" text-xs text-center text-gray-800 dark:text-gray-400 rounded-full px-4 py-0.5 bg-gray-100 dark:bg-gray-850"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
const url = await getGravatarUrl(localStorage.token, $user.email);
|
const url = await getGravatarUrl(localStorage.token, $user?.email);
|
||||||
|
|
||||||
profileImageUrl = url;
|
profileImageUrl = url;
|
||||||
}}>{$i18n.t('Use Gravatar')}</button
|
}}>{$i18n.t('Use Gravatar')}</button
|
||||||
|
@ -308,7 +308,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if $user.role === 'admin' || $user?.permissions.chat?.controls}
|
{#if $user?.role === 'admin' || $user?.permissions.chat?.controls}
|
||||||
<hr class="border-gray-100 dark:border-gray-850 my-3" />
|
<hr class="border-gray-100 dark:border-gray-850 my-3" />
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
|
@ -441,7 +441,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if $user.role === 'admin'}
|
{#if $user?.role === 'admin'}
|
||||||
<div>
|
<div>
|
||||||
<div class=" py-0.5 flex w-full justify-between">
|
<div class=" py-0.5 flex w-full justify-between">
|
||||||
<div class=" self-center text-xs">
|
<div class=" self-center text-xs">
|
||||||
|
@ -462,7 +462,7 @@
|
|||||||
<div class=" self-center">{$i18n.t('Interface')}</div>
|
<div class=" self-center">{$i18n.t('Interface')}</div>
|
||||||
</button>
|
</button>
|
||||||
{:else if tabId === 'connections'}
|
{:else if tabId === 'connections'}
|
||||||
{#if $user.role === 'admin' || ($user.role === 'user' && $config?.features?.enable_direct_connections)}
|
{#if $user?.role === 'admin' || ($user?.role === 'user' && $config?.features?.enable_direct_connections)}
|
||||||
<button
|
<button
|
||||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||||
'connections'
|
'connections'
|
||||||
@ -488,7 +488,7 @@
|
|||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
{:else if tabId === 'tools'}
|
{:else if tabId === 'tools'}
|
||||||
{#if $user.role === 'admin' || ($user.role === 'user' && $config?.features?.enable_direct_tools)}
|
{#if $user?.role === 'admin' || ($user?.role === 'user' && $config?.features?.enable_direct_tools)}
|
||||||
<button
|
<button
|
||||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||||
'tools'
|
'tools'
|
||||||
@ -636,7 +636,7 @@
|
|||||||
<div class=" self-center">{$i18n.t('About')}</div>
|
<div class=" self-center">{$i18n.t('About')}</div>
|
||||||
</button>
|
</button>
|
||||||
{:else if tabId === 'admin'}
|
{:else if tabId === 'admin'}
|
||||||
{#if $user.role === 'admin'}
|
{#if $user?.role === 'admin'}
|
||||||
<button
|
<button
|
||||||
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
class="px-0.5 py-1 min-w-fit rounded-lg flex-1 md:flex-none flex text-left transition {selectedTab ===
|
||||||
'admin'
|
'admin'
|
||||||
|
@ -167,7 +167,7 @@
|
|||||||
{#if $user !== undefined}
|
{#if $user !== undefined}
|
||||||
<UserMenu
|
<UserMenu
|
||||||
className="max-w-[200px]"
|
className="max-w-[200px]"
|
||||||
role={$user.role}
|
role={$user?.role}
|
||||||
on:show={(e) => {
|
on:show={(e) => {
|
||||||
if (e.detail === 'archived-chat') {
|
if (e.detail === 'archived-chat') {
|
||||||
showArchivedChats.set(true);
|
showArchivedChats.set(true);
|
||||||
@ -180,7 +180,7 @@
|
|||||||
>
|
>
|
||||||
<div class=" self-center">
|
<div class=" self-center">
|
||||||
<img
|
<img
|
||||||
src={$user.profile_image_url}
|
src={$user?.profile_image_url}
|
||||||
class="size-6 object-cover rounded-full"
|
class="size-6 object-cover rounded-full"
|
||||||
alt="User profile"
|
alt="User profile"
|
||||||
draggable="false"
|
draggable="false"
|
||||||
|
@ -446,7 +446,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
$socket.emit('join-channels', { auth: { token: $user.token } });
|
$socket.emit('join-channels', { auth: { token: $user?.token } });
|
||||||
await initChannels();
|
await initChannels();
|
||||||
showCreateChannel = false;
|
showCreateChannel = false;
|
||||||
}
|
}
|
||||||
@ -627,13 +627,13 @@
|
|||||||
? 'opacity-20'
|
? '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
|
<Folder
|
||||||
className="px-2 mt-0.5"
|
className="px-2 mt-0.5"
|
||||||
name={$i18n.t('Channels')}
|
name={$i18n.t('Channels')}
|
||||||
dragAndDrop={false}
|
dragAndDrop={false}
|
||||||
onAdd={async () => {
|
onAdd={async () => {
|
||||||
if ($user.role === 'admin') {
|
if ($user?.role === 'admin') {
|
||||||
await tick();
|
await tick();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@ -891,9 +891,9 @@
|
|||||||
|
|
||||||
<div class="px-2">
|
<div class="px-2">
|
||||||
<div class="flex flex-col font-primary">
|
<div class="flex flex-col font-primary">
|
||||||
{#if $user !== undefined}
|
{#if $user !== undefined && $user !== null}
|
||||||
<UserMenu
|
<UserMenu
|
||||||
role={$user.role}
|
role={$user?.role}
|
||||||
on:show={(e) => {
|
on:show={(e) => {
|
||||||
if (e.detail === 'archived-chat') {
|
if (e.detail === 'archived-chat') {
|
||||||
showArchivedChats.set(true);
|
showArchivedChats.set(true);
|
||||||
@ -908,12 +908,12 @@
|
|||||||
>
|
>
|
||||||
<div class=" self-center mr-3">
|
<div class=" self-center mr-3">
|
||||||
<img
|
<img
|
||||||
src={$user.profile_image_url}
|
src={$user?.profile_image_url}
|
||||||
class=" max-w-[30px] object-cover rounded-full"
|
class=" max-w-[30px] object-cover rounded-full"
|
||||||
alt="User profile"
|
alt="User profile"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class=" self-center font-medium">{$user.name}</div>
|
<div class=" self-center font-medium">{$user?.name}</div>
|
||||||
</button>
|
</button>
|
||||||
</UserMenu>
|
</UserMenu>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -55,9 +55,9 @@
|
|||||||
let version;
|
let version;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
if ($user === undefined) {
|
if ($user === undefined || $user === null) {
|
||||||
await goto('/auth');
|
await goto('/auth');
|
||||||
} else if (['user', 'admin'].includes($user.role)) {
|
} else if (['user', 'admin'].includes($user?.role)) {
|
||||||
try {
|
try {
|
||||||
// Check if IndexedDB exists
|
// Check if IndexedDB exists
|
||||||
DB = await openDB('Chats', 1);
|
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);
|
showChangelog.set($settings?.version !== $config.version);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,14 +199,14 @@
|
|||||||
temporaryChatEnabled.set(true);
|
temporaryChatEnabled.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log($user.permissions);
|
console.log($user?.permissions);
|
||||||
|
|
||||||
if ($user?.permissions?.chat?.temporary_enforced) {
|
if ($user?.permissions?.chat?.temporary_enforced) {
|
||||||
temporaryChatEnabled.set(true);
|
temporaryChatEnabled.set(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for version updates
|
// 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
|
// Check if the user has dismissed the update toast in the last 24 hours
|
||||||
if (localStorage.dismissedUpdateToast) {
|
if (localStorage.dismissedUpdateToast) {
|
||||||
const dismissedUpdateToast = new Date(Number(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"
|
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 loaded}
|
||||||
{#if !['user', 'admin'].includes($user.role)}
|
{#if !['user', 'admin'].includes($user?.role)}
|
||||||
<AccountPending />
|
<AccountPending />
|
||||||
{:else if localDBChats.length > 0}
|
{:else if localDBChats.length > 0}
|
||||||
<div class="fixed w-full h-full flex z-50">
|
<div class="fixed w-full h-full flex z-50">
|
||||||
|
Loading…
Reference in New Issue
Block a user