also apply styleDeleted/Added to invisible search results
This commit is contained in:
parent
addc5af96d
commit
78c14dd93c
|
@ -111,6 +111,7 @@ window.addEventListener('showStyles:done', function _() {
|
||||||
dom.list = $('#search-results-list');
|
dom.list = $('#search-results-list');
|
||||||
|
|
||||||
addEventListener('scroll', loadMoreIfNeeded, {passive: true});
|
addEventListener('scroll', loadMoreIfNeeded, {passive: true});
|
||||||
|
|
||||||
if (FIREFOX) {
|
if (FIREFOX) {
|
||||||
let lastScrollbarWidth;
|
let lastScrollbarWidth;
|
||||||
addEventListener('resize', () => {
|
addEventListener('resize', () => {
|
||||||
|
@ -125,22 +126,22 @@ window.addEventListener('showStyles:done', function _() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
addEventListener('styleDeleted', ({detail}) => {
|
addEventListener('styleDeleted', ({detail: {id}}) => {
|
||||||
const entries = [...dom.list.children];
|
const result = processedResults.find(r => r.installedStyleId === id);
|
||||||
const entry = entries.find(el => el._result.installedStyleId === detail.id);
|
if (result) {
|
||||||
if (entry) {
|
result.installed = false;
|
||||||
entry._result.installed = false;
|
result.installedStyleId = -1;
|
||||||
renderActionButtons(entry);
|
renderActionButtons($('#' + RESULT_ID_PREFIX + result.id));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
addEventListener('styleAdded', ({detail: {style: {id, md5Url}}}) => {
|
addEventListener('styleAdded', ({detail: {style: {id, md5Url}}}) => {
|
||||||
const usoId = md5Url && md5Url.match(/\d+|$/)[0];
|
const usoId = parseInt(md5Url && md5Url.match(/\d+|$/)[0]);
|
||||||
const entry = usoId && $('#' + RESULT_ID_PREFIX + usoId);
|
const result = usoId && processedResults.find(r => r.id === usoId);
|
||||||
if (entry) {
|
if (result) {
|
||||||
entry._result.installed = true;
|
result.installed = true;
|
||||||
entry._result.installedStyleId = id;
|
result.installedStyleId = id;
|
||||||
renderActionButtons(entry);
|
renderActionButtons($('#' + RESULT_ID_PREFIX + usoId));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -488,6 +489,9 @@ window.addEventListener('showStyles:done', function _() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderActionButtons(entry) {
|
function renderActionButtons(entry) {
|
||||||
|
if (!entry) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const result = entry._result;
|
const result = entry._result;
|
||||||
|
|
||||||
if (result.installed && !('installed' in entry.dataset)) {
|
if (result.installed && !('installed' in entry.dataset)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user