keep selected sender from hash until user selects others

This commit is contained in:
lilydjwg 2021-10-24 21:08:33 +08:00
parent acf925e616
commit 5e7e55b485
2 changed files with 8 additions and 4 deletions

View File

@ -15,6 +15,7 @@
let loading = false
let need_update_title = false
let sender
let selected_init
setContext('LUOXU_URL', LUOXU_URL)
@ -79,6 +80,7 @@
}
if(info.has('sender')) {
sender = info.get('sender')
selected_init = sender
}
if((group || islocal) && query) {
result = null
@ -176,7 +178,7 @@
on:input={() => error = ''}
on:keydown={e => {if(e.key == 'Enter'){do_search()}}}
/>
<Name group={group} bind:selected={sender}/>
<Name group={group} bind:selected={sender} selected_init={selected_init}/>
<button on:click={() => do_search()}>搜索</button>
</div>

View File

@ -4,6 +4,7 @@
export let group
export let selected
export let selected_init
let selected_name = ''
let selected_idx
@ -76,16 +77,17 @@
selected = names[selected_idx][0]
selected_name = names[selected_idx][1]
input.value = selected_name
selected_init = null
}
function update_value() {
if(!selected) {
if(!selected || selected === selected_init) {
return
}
if(input.value) {
input.value = selected_name
}else{
selected = null
selected = selected_init
selected_name = ''
}
}
@ -118,7 +120,7 @@
}
}
}
// TODO: NOT operator
</script>
<div>