fix searchbar reset on redraw

This commit is contained in:
rottencandy 2019-08-14 18:10:32 +05:30
parent 73c609578a
commit f5ea8e59cd
2 changed files with 18 additions and 9 deletions

View File

@ -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'),

View File

@ -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;