manage: fixup style search

This commit is contained in:
tophf 2017-03-26 11:57:44 +03:00
parent 2fb046e996
commit 55ac677d85

View File

@ -425,20 +425,23 @@ class Updater {
function searchStyles({immediately, container}) { function searchStyles({immediately, container}) {
const query = $('#search').value.toLocaleLowerCase(); const query = $('#search').value.toLocaleLowerCase();
if (query == (searchStyles.lastQuery || '') && !container) { if (query == (searchStyles.lastQuery || '') && !immediately && !container) {
return; return;
} }
searchStyles.lastQuery = query; searchStyles.lastQuery = query;
if (!immediately) { if (!immediately) {
clearTimeout(searchStyles.timeout); clearTimeout(searchStyles.timeout);
searchStyles.timeout = setTimeout(searchStyles, 200, {immediately: true}); searchStyles.timeout = setTimeout(searchStyles, 150, {immediately: true});
return; return;
} }
for (const element of (container || installed).children) { for (const element of (container || installed).children) {
const {style} = cachedStyles.byId.get(element.styleId) || {}; const {style} = cachedStyles.byId.get(element.styleId) || {};
if (style) { if (style) {
const isMatching = !query || isMatchingText(style.name) || isMatchingStyle(style); const isMatching = !query
|| isMatchingText(style.name)
|| style.url && isMatchingText(style.url)
|| isMatchingStyle(style);
element.style.display = isMatching ? '' : 'none'; element.style.display = isMatching ? '' : 'none';
} }
} }