From 5e7e55b4859995306697074649e6abeed1a7ec96 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Sun, 24 Oct 2021 21:08:33 +0800 Subject: [PATCH] keep selected sender from hash until user selects others --- src/App.svelte | 4 +++- src/Name.svelte | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 5a98617..a313604 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -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()}}} /> - + diff --git a/src/Name.svelte b/src/Name.svelte index 68c3a1d..050c61c 100644 --- a/src/Name.svelte +++ b/src/Name.svelte @@ -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 +