refac: temporary chat behaviour

This commit is contained in:
Timothy Jaeryang Baek 2025-05-10 22:12:36 +04:00
parent be85f7cc35
commit ba69c751ca
2 changed files with 26 additions and 22 deletions

View File

@ -155,12 +155,14 @@
localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`) localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)
); );
prompt = input.prompt; if (!$temporaryChatEnabled) {
files = input.files; prompt = input.prompt;
selectedToolIds = input.selectedToolIds; files = input.files;
webSearchEnabled = input.webSearchEnabled; selectedToolIds = input.selectedToolIds;
imageGenerationEnabled = input.imageGenerationEnabled; webSearchEnabled = input.webSearchEnabled;
codeInterpreterEnabled = input.codeInterpreterEnabled; imageGenerationEnabled = input.imageGenerationEnabled;
codeInterpreterEnabled = input.codeInterpreterEnabled;
}
} catch (e) {} } catch (e) {}
} }
@ -419,25 +421,27 @@
} }
if (localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) { if (localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) {
prompt = '';
files = [];
selectedToolIds = [];
webSearchEnabled = false;
imageGenerationEnabled = false;
codeInterpreterEnabled = false;
try { try {
const input = JSON.parse( const input = JSON.parse(
localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`) localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)
); );
console.log('chat-input', input);
prompt = input.prompt; if (!$temporaryChatEnabled) {
files = input.files; prompt = input.prompt;
selectedToolIds = input.selectedToolIds; files = input.files;
webSearchEnabled = input.webSearchEnabled; selectedToolIds = input.selectedToolIds;
imageGenerationEnabled = input.imageGenerationEnabled; webSearchEnabled = input.webSearchEnabled;
codeInterpreterEnabled = input.codeInterpreterEnabled; imageGenerationEnabled = input.imageGenerationEnabled;
} catch (e) { codeInterpreterEnabled = input.codeInterpreterEnabled;
prompt = ''; }
files = []; } catch (e) {}
selectedToolIds = [];
webSearchEnabled = false;
imageGenerationEnabled = false;
codeInterpreterEnabled = false;
}
} }
if (!chatIdProp) { if (!chatIdProp) {

View File

@ -196,7 +196,7 @@
showChangelog.set($settings?.version !== $config.version); showChangelog.set($settings?.version !== $config.version);
} }
if ($user?.permissions?.chat?.temporary ?? true) { if ($user?.role === 'admin' || ($user?.permissions?.chat?.temporary ?? true)) {
if ($page.url.searchParams.get('temporary-chat') === 'true') { if ($page.url.searchParams.get('temporary-chat') === 'true') {
temporaryChatEnabled.set(true); temporaryChatEnabled.set(true);
} }