Skip to content

Commit f144bcf

Browse files
committed
Bug corrections
1 parent 620fc1e commit f144bcf

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

js/script.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
let can_delete_history = false;
22
let max_chats_history = 512;
3+
let save_history = true;
34
let chosen_platform = localStorage.getItem('chosen_platform');
45
let model = localStorage.getItem('selected_model');
56
let is_mobile = window.matchMedia("(max-width: 768px)").matches;
@@ -338,14 +339,17 @@ function addConversation(role, content, add_to_document = true, do_scroll = true
338339

339340

340341
function saveLocalHistory() {
341-
try {
342-
localStorage.setItem(chat_id.toString(), JSON.stringify(conversations));
343-
}catch (e) {
344-
if (e.name === 'QuotaExceededError' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED'){
345-
addWarning('Your browser has reached the maximum number of items allowed for local storage.' +
346-
' Please clear out some old chats to free up space.', false);
347-
}
348-
}
342+
if(save_history){
343+
try {
344+
localStorage.setItem(chat_id.toString(), JSON.stringify(conversations));
345+
}catch (e) {
346+
if (e.name === 'QuotaExceededError' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED'){
347+
addWarning('Your browser has reached the maximum number of items allowed for local storage.' +
348+
' Please clear out some old chats to free up space.', false);
349+
}
350+
}
351+
}
352+
save_history = true;
349353
loadOldChatTopics();
350354
}
351355

@@ -1186,6 +1190,7 @@ function geminiChat(fileUri = '', with_stream = true, the_data = '') {
11861190
data.generationConfig.thinkingConfig = { thinkingBudget: 8000 };
11871191
}
11881192
if(pog === 'pic' || pog === 'imagine'){
1193+
save_history = false;
11891194
console.log('image generation command activated');
11901195
gemini_model = "gemini-2.0-flash-preview-image-generation";
11911196
}
@@ -2823,7 +2828,7 @@ async function geminiStreamChat(fileUri, data, allow_tool_use = true) {
28232828
})
28242829
if (story) {
28252830
// remove base64 image to save tokens
2826-
conversations.messages[conversations.messages.length - 1].content = story.replace(/<img[^>]*>/g, '');
2831+
conversations.messages[conversations.messages.length - 1].content = story.replace(/<img[^>]*>/g, ' ');
28272832
saveLocalHistory();
28282833
botMessageDiv.innerHTML = converter.makeHtml(story);
28292834
}

0 commit comments

Comments
 (0)