fix(theseus/settings): Aegis card reads correct IPC shapes
CDP test surfaced two shape mismatches:
- cfg.listAddons() returns {installed:[...], sidebarPanels:[...]} — my
destructure treated it as a plain array, so .find() blew up with
'installed || []).find is not a function'.
- cfg.checkAddonUpdates() returns {report, skipped, staged:[...]} —
same problem, .find on an object.
Both call sites now normalise (installed = listRes.installed || [],
staged = res.staged || []) before finding the aegis entry. Verified
via CDP against a fresh install: card renders 'You're on v0.4.0.
Updates arrive over-the-air…'; clicking Check for updates keeps
that status (no staged update live); Restart-to-apply stays hidden.
This commit is contained in:
parent
2c7b82ad60
commit
1f63b5b788
1 changed files with 12 additions and 6 deletions
|
|
@ -1009,15 +1009,20 @@
|
|||
const aegisCheck = document.getElementById("aegisCheck");
|
||||
const aegisApply = document.getElementById("aegisApply");
|
||||
const isAegis = (a) => a && (a.id === "aegis" || a.id === "bchwallet");
|
||||
// addons-list returns {installed:[...], sidebarPanels:[...]}
|
||||
// addons-check-updates returns {report, skipped, staged:[...]}
|
||||
// addons-list-staged returns a flat [...]. Normalise both call sites.
|
||||
async function refreshAegis() {
|
||||
aegisApply.hidden = true;
|
||||
try {
|
||||
const [installed, staged] = await Promise.all([
|
||||
C.listAddons ? C.listAddons() : Promise.resolve([]),
|
||||
const [listRes, stagedRes] = await Promise.all([
|
||||
C.listAddons ? C.listAddons() : Promise.resolve({}),
|
||||
C.listStagedAddonUpdates ? C.listStagedAddonUpdates() : Promise.resolve([]),
|
||||
]);
|
||||
const cur = (installed || []).find(isAegis);
|
||||
const upd = (staged || []).find(isAegis);
|
||||
const installed = (listRes && listRes.installed) || [];
|
||||
const staged = Array.isArray(stagedRes) ? stagedRes : [];
|
||||
const cur = installed.find(isAegis);
|
||||
const upd = staged.find(isAegis);
|
||||
if (!cur) { aegisStatus.textContent = "Aegis isn't installed. Reinstall Theseus to add it back, or open Settings > Extensions to load it manually."; return; }
|
||||
const curVer = cur.version || "?";
|
||||
if (upd && upd.version) {
|
||||
|
|
@ -1033,8 +1038,9 @@
|
|||
aegisCheck.disabled = true; aegisCheck.textContent = "Checking…";
|
||||
aegisStatus.textContent = "Checking…";
|
||||
try {
|
||||
const staged = await (C.checkAddonUpdates ? C.checkAddonUpdates() : Promise.resolve([]));
|
||||
const upd = (staged || []).find(isAegis);
|
||||
const res = await (C.checkAddonUpdates ? C.checkAddonUpdates() : Promise.resolve({}));
|
||||
const staged = (res && Array.isArray(res.staged)) ? res.staged : [];
|
||||
const upd = staged.find(isAegis);
|
||||
if (!upd) { aegisStatus.textContent = "You're on the latest Aegis."; }
|
||||
// refresh will populate everything else + toggle the Apply button
|
||||
refreshAegis();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue