Retry icons the shell couldn't draw; draw from the listed activities

On a phone the first dozen apps in the drawer kept coming back without an
icon. Icons are now drawn from the LauncherActivityInfo objects apps.json
was built from (falling back to resolveActivity), failures are logged
under "ultra" with the reason, and the page asks again for any icon that
came back empty, up to three times with backoff.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019EEjkJVV72Lu8ndDVWg5BT
This commit is contained in:
Claude committed 2026-10-21 21:45:59 +00:00
1 parent 0a9f4f5ec9
commit 8196e06391
2 files changed
+30 -5

No files matched your search

+16 -2
View File
@@ -75,9 +75,23 @@
if (host.loadIcons) host.loadIcons(JSON.stringify(want));
else gotIcons(Object.fromEntries(want.map((k) => [k, k])));
};
// An icon the shell couldn't draw ("") is asked for again, up to 3 times, with backoff;
// until then, and after, it shows as a blank disc.
const tries = new Map();
const gotIcons = (batch) => {
for (const k in batch) { iconSrc.set(k, batch[k]); asked.delete(k); }
const again = [];
for (const k in batch) {
iconSrc.set(k, batch[k]); asked.delete(k);
const n = tries.get(k) || 0;
if (!batch[k] && n < 3) { tries.set(k, n + 1); again.push(k); }
}
fillIcons();
if (again.length) setTimeout(() => {
for (const k of again) iconSrc.delete(k);
for (const img of document.querySelectorAll("img.icon[data-icon]"))
if (again.includes(img.dataset.icon)) img.__icon = undefined;
fillIcons();
}, 800 * (tries.get(again[0]) || 1));
};
window.ultraIcons = gotIcons; // the shell calls this before ultraHome exists, too
@@ -108,7 +122,7 @@
widgetAdded: (id) => app.dispatch(WIDGET_ADDED, id),
widgetMenu: (id) => app.dispatch(WIDGET_MENU, id),
place: () => { placed = ""; place(); },
resetIcons: () => { iconSrc.clear(); asked.clear();
resetIcons: () => { iconSrc.clear(); asked.clear(); tries.clear();
for (const img of document.querySelectorAll("img.icon")) img.__icon = undefined; },
};
document.addEventListener("visibilitychange", () => { if (!document.hidden) window.ultraHome.tick(); });