mirror of
https://github.com/open-webui/open-webui
synced 2025-06-23 02:16:52 +00:00
refac: chat input object localStorage -> sessionStorage
This commit is contained in:
parent
34440f95dc
commit
1547235d47
@ -347,6 +347,8 @@ export const userSignOut = async () => {
|
|||||||
if (error) {
|
if (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sessionStorage.clear();
|
||||||
return res;
|
return res;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -153,10 +153,10 @@
|
|||||||
webSearchEnabled = false;
|
webSearchEnabled = false;
|
||||||
imageGenerationEnabled = false;
|
imageGenerationEnabled = false;
|
||||||
|
|
||||||
if (localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) {
|
if (sessionStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) {
|
||||||
try {
|
try {
|
||||||
const input = JSON.parse(
|
const input = JSON.parse(
|
||||||
localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)
|
sessionStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$temporaryChatEnabled) {
|
if (!$temporaryChatEnabled) {
|
||||||
@ -446,7 +446,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) {
|
if (sessionStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) {
|
||||||
prompt = '';
|
prompt = '';
|
||||||
files = [];
|
files = [];
|
||||||
selectedToolIds = [];
|
selectedToolIds = [];
|
||||||
@ -457,7 +457,7 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const input = JSON.parse(
|
const input = JSON.parse(
|
||||||
localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)
|
sessionStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!$temporaryChatEnabled) {
|
if (!$temporaryChatEnabled) {
|
||||||
@ -2120,12 +2120,12 @@
|
|||||||
onChange={(input) => {
|
onChange={(input) => {
|
||||||
if (!$temporaryChatEnabled) {
|
if (!$temporaryChatEnabled) {
|
||||||
if (input.prompt !== null) {
|
if (input.prompt !== null) {
|
||||||
localStorage.setItem(
|
sessionStorage.setItem(
|
||||||
`chat-input${$chatId ? `-${$chatId}` : ''}`,
|
`chat-input${$chatId ? `-${$chatId}` : ''}`,
|
||||||
JSON.stringify(input)
|
JSON.stringify(input)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
localStorage.removeItem(`chat-input${$chatId ? `-${$chatId}` : ''}`);
|
sessionStorage.removeItem(`chat-input${$chatId ? `-${$chatId}` : ''}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@ -164,7 +164,9 @@
|
|||||||
<Tooltip
|
<Tooltip
|
||||||
className=" w-fit"
|
className=" w-fit"
|
||||||
content={marked.parse(
|
content={marked.parse(
|
||||||
sanitizeResponseContent(models[selectedModelIdx]?.info?.meta?.description ?? '').replaceAll('\n', '<br>')
|
sanitizeResponseContent(
|
||||||
|
models[selectedModelIdx]?.info?.meta?.description ?? ''
|
||||||
|
).replaceAll('\n', '<br>')
|
||||||
)}
|
)}
|
||||||
placement="top"
|
placement="top"
|
||||||
>
|
>
|
||||||
@ -172,7 +174,9 @@
|
|||||||
class="mt-0.5 px-2 text-sm font-normal text-gray-500 dark:text-gray-400 line-clamp-2 max-w-xl markdown"
|
class="mt-0.5 px-2 text-sm font-normal text-gray-500 dark:text-gray-400 line-clamp-2 max-w-xl markdown"
|
||||||
>
|
>
|
||||||
{@html marked.parse(
|
{@html marked.parse(
|
||||||
sanitizeResponseContent(models[selectedModelIdx]?.info?.meta?.description ?? '').replaceAll('\n', '<br>')
|
sanitizeResponseContent(
|
||||||
|
models[selectedModelIdx]?.info?.meta?.description ?? ''
|
||||||
|
).replaceAll('\n', '<br>')
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
@ -218,9 +222,9 @@
|
|||||||
onChange={(input) => {
|
onChange={(input) => {
|
||||||
if (!$temporaryChatEnabled) {
|
if (!$temporaryChatEnabled) {
|
||||||
if (input.prompt !== null) {
|
if (input.prompt !== null) {
|
||||||
localStorage.setItem(`chat-input`, JSON.stringify(input));
|
sessionStorage.setItem(`chat-input`, JSON.stringify(input));
|
||||||
} else {
|
} else {
|
||||||
localStorage.removeItem(`chat-input`);
|
sessionStorage.removeItem(`chat-input`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
@ -78,9 +78,7 @@
|
|||||||
// IndexedDB Not Found
|
// IndexedDB Not Found
|
||||||
}
|
}
|
||||||
|
|
||||||
const chatInputKeys = Object.keys(localStorage).filter((key) =>
|
const chatInputKeys = Object.keys(localStorage).filter((key) => key.startsWith('chat-input'));
|
||||||
key.startsWith('chat-input-')
|
|
||||||
);
|
|
||||||
if (chatInputKeys.length > 0) {
|
if (chatInputKeys.length > 0) {
|
||||||
chatInputKeys.forEach((key) => {
|
chatInputKeys.forEach((key) => {
|
||||||
localStorage.removeItem(key);
|
localStorage.removeItem(key);
|
||||||
|
Loading…
Reference in New Issue
Block a user