From f5ea8e59cd547137c44799145729378c28e3d19f Mon Sep 17 00:00:00 2001 From: rottencandy Date: Wed, 14 Aug 2019 18:10:32 +0530 Subject: [PATCH] fix searchbar reset on redraw --- webui-src/app/files/files_downloads.js | 22 +++++++++++++++------- webui-src/app/files/files_util.js | 5 +++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/webui-src/app/files/files_downloads.js b/webui-src/app/files/files_downloads.js index 5138f87..5fd9bd7 100644 --- a/webui-src/app/files/files_downloads.js +++ b/webui-src/app/files/files_downloads.js @@ -56,6 +56,11 @@ let Downloads = { updateFileDetail(hash); } }, + resetSearch() { + for(let hash in Downloads.statusMap) { + Downloads.statusMap[hash].isSearched = true; + } + }, }; function InvalidFileMessage() { @@ -114,13 +119,16 @@ NewFileDialog = () => { const Component = () => { return { - oninit: () => rs.setBackgroundTask( - Downloads.loadStatus, - 1000, - () => { - return (m.route.get() === '/files') - } - ), + oninit: () => { + rs.setBackgroundTask( + Downloads.loadStatus, + 1000, + () => { + return (m.route.get() === '/files') + } + ); + Downloads.resetSearch(); + }, view: () => m('.widget', [ m('h3', 'Downloads'), m('hr'), diff --git a/webui-src/app/files/files_util.js b/webui-src/app/files/files_util.js index 79a0017..cf0dbf9 100644 --- a/webui-src/app/files/files_util.js +++ b/webui-src/app/files/files_util.js @@ -127,8 +127,8 @@ const File = () => { } }; -let searchString = ''; const SearchBar = () => { + let searchString = ''; return { view: (v) => m('input[type=text][placeholder=search].searchbar', { @@ -136,7 +136,8 @@ const SearchBar = () => { oninput: (e) => { searchString = e.target.value.toLowerCase(); for(let hash in v.attrs.list) { - if(v.attrs.list[hash].fname.toLowerCase().indexOf(searchString) > -1) { + if(v.attrs.list[hash].fname.toLowerCase().indexOf( + searchString) > -1) { v.attrs.list[hash].isSearched = true; } else { v.attrs.list[hash].isSearched = false;