Keldos commited on
Commit
c643b5b
·
1 Parent(s): d93889b

fix: 修复清空聊天框后刷新页面仍只读历史记录的问题

Browse files
web_assets/javascript/chat-history.js CHANGED
@@ -13,7 +13,9 @@ function saveHistoryHtml() {
13
 
14
  function loadHistoryHtml() {
15
  var historyHtml = localStorage.getItem('chatHistory');
16
- if (!historyHtml) {
 
 
17
  historyLoaded = true;
18
  return; // no history, do nothing
19
  }
@@ -23,8 +25,6 @@ function loadHistoryHtml() {
23
  return; // logged in, do nothing
24
  }
25
  if (!historyLoaded) {
26
- var tempDiv = document.createElement('div');
27
- tempDiv.innerHTML = historyHtml;
28
  var buttons = tempDiv.querySelectorAll('button.chuanhu-btn');
29
  var gradioCopyButtons = tempDiv.querySelectorAll('button.copy_code_button');
30
  for (var i = 0; i < buttons.length; i++) {
 
13
 
14
  function loadHistoryHtml() {
15
  var historyHtml = localStorage.getItem('chatHistory');
16
+ const tempDiv = document.createElement('div');
17
+ tempDiv.innerHTML = historyHtml;
18
+ if (!historyHtml || tempDiv.innerText.trim() === "") {
19
  historyLoaded = true;
20
  return; // no history, do nothing
21
  }
 
25
  return; // logged in, do nothing
26
  }
27
  if (!historyLoaded) {
 
 
28
  var buttons = tempDiv.querySelectorAll('button.chuanhu-btn');
29
  var gradioCopyButtons = tempDiv.querySelectorAll('button.copy_code_button');
30
  for (var i = 0; i < buttons.length; i++) {