mirror of
				https://github.com/open-webui/open-webui
				synced 2025-06-26 18:26:48 +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) {
 | 
			
		||||
		throw error;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	sessionStorage.clear();
 | 
			
		||||
	return res;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -153,10 +153,10 @@
 | 
			
		||||
			webSearchEnabled = false;
 | 
			
		||||
			imageGenerationEnabled = false;
 | 
			
		||||
 | 
			
		||||
			if (localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) {
 | 
			
		||||
			if (sessionStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) {
 | 
			
		||||
				try {
 | 
			
		||||
					const input = JSON.parse(
 | 
			
		||||
						localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)
 | 
			
		||||
						sessionStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)
 | 
			
		||||
					);
 | 
			
		||||
 | 
			
		||||
					if (!$temporaryChatEnabled) {
 | 
			
		||||
@ -446,7 +446,7 @@
 | 
			
		||||
			}
 | 
			
		||||
		});
 | 
			
		||||
 | 
			
		||||
		if (localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) {
 | 
			
		||||
		if (sessionStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)) {
 | 
			
		||||
			prompt = '';
 | 
			
		||||
			files = [];
 | 
			
		||||
			selectedToolIds = [];
 | 
			
		||||
@ -457,7 +457,7 @@
 | 
			
		||||
 | 
			
		||||
			try {
 | 
			
		||||
				const input = JSON.parse(
 | 
			
		||||
					localStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)
 | 
			
		||||
					sessionStorage.getItem(`chat-input${chatIdProp ? `-${chatIdProp}` : ''}`)
 | 
			
		||||
				);
 | 
			
		||||
 | 
			
		||||
				if (!$temporaryChatEnabled) {
 | 
			
		||||
@ -2120,12 +2120,12 @@
 | 
			
		||||
									onChange={(input) => {
 | 
			
		||||
										if (!$temporaryChatEnabled) {
 | 
			
		||||
											if (input.prompt !== null) {
 | 
			
		||||
												localStorage.setItem(
 | 
			
		||||
												sessionStorage.setItem(
 | 
			
		||||
													`chat-input${$chatId ? `-${$chatId}` : ''}`,
 | 
			
		||||
													JSON.stringify(input)
 | 
			
		||||
												);
 | 
			
		||||
											} else {
 | 
			
		||||
												localStorage.removeItem(`chat-input${$chatId ? `-${$chatId}` : ''}`);
 | 
			
		||||
												sessionStorage.removeItem(`chat-input${$chatId ? `-${$chatId}` : ''}`);
 | 
			
		||||
											}
 | 
			
		||||
										}
 | 
			
		||||
									}}
 | 
			
		||||
 | 
			
		||||
@ -164,7 +164,9 @@
 | 
			
		||||
						<Tooltip
 | 
			
		||||
							className=" w-fit"
 | 
			
		||||
							content={marked.parse(
 | 
			
		||||
								sanitizeResponseContent(models[selectedModelIdx]?.info?.meta?.description ?? '').replaceAll('\n', '<br>')
 | 
			
		||||
								sanitizeResponseContent(
 | 
			
		||||
									models[selectedModelIdx]?.info?.meta?.description ?? ''
 | 
			
		||||
								).replaceAll('\n', '<br>')
 | 
			
		||||
							)}
 | 
			
		||||
							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"
 | 
			
		||||
							>
 | 
			
		||||
								{@html marked.parse(
 | 
			
		||||
									sanitizeResponseContent(models[selectedModelIdx]?.info?.meta?.description ?? '').replaceAll('\n', '<br>')
 | 
			
		||||
									sanitizeResponseContent(
 | 
			
		||||
										models[selectedModelIdx]?.info?.meta?.description ?? ''
 | 
			
		||||
									).replaceAll('\n', '<br>')
 | 
			
		||||
								)}
 | 
			
		||||
							</div>
 | 
			
		||||
						</Tooltip>
 | 
			
		||||
@ -218,9 +222,9 @@
 | 
			
		||||
					onChange={(input) => {
 | 
			
		||||
						if (!$temporaryChatEnabled) {
 | 
			
		||||
							if (input.prompt !== null) {
 | 
			
		||||
								localStorage.setItem(`chat-input`, JSON.stringify(input));
 | 
			
		||||
								sessionStorage.setItem(`chat-input`, JSON.stringify(input));
 | 
			
		||||
							} else {
 | 
			
		||||
								localStorage.removeItem(`chat-input`);
 | 
			
		||||
								sessionStorage.removeItem(`chat-input`);
 | 
			
		||||
							}
 | 
			
		||||
						}
 | 
			
		||||
					}}
 | 
			
		||||
 | 
			
		||||
@ -78,9 +78,7 @@
 | 
			
		||||
				// IndexedDB Not Found
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			const chatInputKeys = Object.keys(localStorage).filter((key) =>
 | 
			
		||||
				key.startsWith('chat-input-')
 | 
			
		||||
			);
 | 
			
		||||
			const chatInputKeys = Object.keys(localStorage).filter((key) => key.startsWith('chat-input'));
 | 
			
		||||
			if (chatInputKeys.length > 0) {
 | 
			
		||||
				chatInputKeys.forEach((key) => {
 | 
			
		||||
					localStorage.removeItem(key);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user