Skip to content

Commit c4188a0

Browse files
perf: Assistant refresh
1 parent 87c56e2 commit c4188a0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

frontend/public/assistant.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -485,7 +485,7 @@
485485
expposeGlobalMethods(id)
486486
})
487487
}
488-
function updateOnlineParam(target_url, newValue) {
488+
function updateParam(target_url, key, newValue) {
489489
try {
490490
const url = new URL(target_url)
491491
const [hashPath, hashQuery] = url.hash.split('?')
@@ -495,7 +495,7 @@
495495
} else {
496496
searchParams = url.searchParams
497497
}
498-
searchParams.set('online', newValue)
498+
searchParams.set(key, newValue)
499499
if (hashQuery) {
500500
url.hash = `${hashPath}?${searchParams.toString()}`
501501
} else {
@@ -533,11 +533,14 @@
533533
const iframe = document.getElementById(`sqlbot-assistant-chat-iframe-${id}`)
534534
if (iframe) {
535535
const url = iframe.src
536-
let new_url = `${url}&t=${Date.now()}`
536+
let new_url = updateParam(url, 't', Date.now())
537537
if (online != null) {
538-
new_url = updateOnlineParam(new_url, online)
538+
new_url = updateParam(new_url, 'online', online)
539539
}
540-
iframe.src = new_url
540+
iframe.src = 'about:blank'
541+
setTimeout(() => {
542+
iframe.src = new_url
543+
}, 500)
541544
}
542545
}
543546
}

0 commit comments

Comments
 (0)