Skip to content

Commit

Permalink
extension/*: subscribeToExtension: process all updates, use more spec…
Browse files Browse the repository at this point in the history
…ific `isSafe` functions

This fixes some potential state display inconsistency bugs and improves UI
pages' init performance when the core is very busy.

Also, with this the logic inside `processUpdate` functions in the future patches
becomes way too complex.
  • Loading branch information
oxij committed Nov 5, 2024
1 parent d1c0b32 commit 01e6526
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
6 changes: 0 additions & 6 deletions extension/lib/lutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ function showSaved(suffix, ...args) {
return showInternalPageAtNode("/page/saved.html" + suffix, ...args);
}

// a filter for core events that can be ignored without causing inconsistencies
function thisIsFine(event) {
// it usually isn't, isn't it?
return false;
}

function setPageLoading() {
document.getElementById("body_loading").innerHTML = "<p>Loading...</p>";
}
Expand Down
2 changes: 0 additions & 2 deletions extension/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,8 +864,6 @@ function subscribeToExtension(processUpdate, reinit, isSafe, markLoading, markSe
}
function processUpdateSmartly(event) {
shouldReset = shouldReset || !isSafe(event);
if (shouldReset)
return;
// apparently, this event can be processed synchronously
processUpdateSync(event);
}
Expand Down
5 changes: 4 additions & 1 deletion extension/page/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,10 @@ async function popupMain() {
await updateTabConfig();
await updateTabStats();
}
}), thisIsFine, setPageLoading, setPageSettling);
}), (event) => {
let cmd = event[0];
return !cmd.startsWith("update");
}, setPageLoading, setPageSettling);

// show UI
setPageLoaded();
Expand Down
2 changes: 1 addition & 1 deletion extension/page/saved.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ async function stateMain() {

await subscribeToExtension(catchAll(processUpdate), catchAll(async (willReset) => {
await updateConfig();
}), thisIsFine, setPageLoading, setPageSettling);
}), () => true, setPageLoading, setPageSettling);

let rrfilters = await browser.runtime.sendMessage(["getSavedFilters"]);
await browser.runtime.sendMessage(["setSavedFilters", rrfilters]);
Expand Down
5 changes: 4 additions & 1 deletion extension/page/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,10 @@ async function stateMain() {
resetLog(log);
resetQueued(queuedLog);
resetUnarchived(unarchivedLog);
}), thisIsFine, setPageLoading, setPageSettling);
}), (event) => {
let cmd = event[0];
return !(cmd.startsWith("reset") || cmd.startsWith("new"));
}, setPageLoading, setPageSettling);

// show UI
setPageLoaded();
Expand Down

0 comments on commit 01e6526

Please sign in to comment.