avoid triggering search again while updating location.hash

This commit is contained in:
lilydjwg 2021-10-24 21:15:59 +08:00
parent 5e7e55b485
commit 83597d2b1d

View File

@ -16,6 +16,7 @@
let need_update_title = false let need_update_title = false
let sender let sender
let selected_init let selected_init
let our_hash_change = false
setContext('LUOXU_URL', LUOXU_URL) setContext('LUOXU_URL', LUOXU_URL)
@ -99,6 +100,7 @@
return return
} }
error = '' error = ''
our_hash_change = true
console.log(`searching ${query} for group ${group}, older than ${more}, from ${sender}`) console.log(`searching ${query} for group ${group}, older than ${more}, from ${sender}`)
const q = new URLSearchParams() const q = new URLSearchParams()
if(group) { if(group) {
@ -138,6 +140,7 @@
error = e error = e
loading = false loading = false
} }
our_hash_change = false;
} }
async function on_group_change() { async function on_group_change() {
@ -156,7 +159,7 @@
} }
</script> </script>
<svelte:window on:hashchange={do_hash_search}/> <svelte:window on:hashchange={() => {if(!our_hash_change) do_hash_search()}}/>
<main> <main>
<div id="searchbox"> <div id="searchbox">