improve logic for tempchat enabled

This commit is contained in:
Erik 2025-04-01 09:19:42 +02:00
parent 70bb0562f3
commit c68e18cf7e

View File

@ -195,13 +195,16 @@
showChangelog.set($settings?.version !== $config.version); showChangelog.set($settings?.version !== $config.version);
} }
if ($page.url.searchParams.get('temporary-chat') === 'true') { // check if searchParam is set, if yes & user is allowed to use param, then param > permission
// If "temporary-chat=true" is set in the URL, always enable temporary chat
const searchParam = $page.url.searchParams.get('temporary-chat');
if (searchParam === 'true') {
temporaryChatEnabled.set(true); temporaryChatEnabled.set(true);
} // If "temporary-chat=false" is set in the URL, always disable temporary chat
} else if (searchParam === 'false') {
console.log($user?.permissions); temporaryChatEnabled.set(false);
// If "temporary-chat" is not set in the URL, check if user has permission to use temporary chat
if ($user?.permissions?.chat?.temporary_enforced) { } else if ($user?.permissions?.chat?.temporary_enforced) {
temporaryChatEnabled.set(true); temporaryChatEnabled.set(true);
} }