Enhance HUD dot functionality: add context validation and error handling, update member index from shared index if empty
This commit is contained in:
parent
5bbeac5e89
commit
7ccc73bf03
17
content.js
17
content.js
@ -726,6 +726,8 @@ function ensureHudDot() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function updateHudDot() {
|
function updateHudDot() {
|
||||||
|
if (contextInvalidated || !document?.body) return;
|
||||||
|
try {
|
||||||
const dot = ensureHudDot();
|
const dot = ensureHudDot();
|
||||||
const panel = document.getElementById(HUD_PANEL_ID);
|
const panel = document.getElementById(HUD_PANEL_ID);
|
||||||
const total = sharedIndex.size;
|
const total = sharedIndex.size;
|
||||||
@ -745,6 +747,9 @@ function updateHudDot() {
|
|||||||
hudDirty = false;
|
hudDirty = false;
|
||||||
lastHudSignature = signature;
|
lastHudSignature = signature;
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
contextInvalidated = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function flashHudDot() {
|
function flashHudDot() {
|
||||||
@ -906,6 +911,18 @@ function loadStoredIndex() {
|
|||||||
data[STORAGE_KEY_MEMBER].forEach(item =>
|
data[STORAGE_KEY_MEMBER].forEach(item =>
|
||||||
sharedMemberIndex.set(item.id, item)
|
sharedMemberIndex.set(item.id, item)
|
||||||
);
|
);
|
||||||
|
if (sharedMemberIndex.size === 0 && sharedIndex.size > 0) {
|
||||||
|
for (const item of sharedIndex.values()) {
|
||||||
|
sharedMemberIndex.set(item.id, {
|
||||||
|
id: item.id,
|
||||||
|
channelKey: item.channelKey,
|
||||||
|
channelLabel: item.channelLabel,
|
||||||
|
channelUrl: item.channelUrl,
|
||||||
|
lastSeen: item.lastSeen || Date.now()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
schedulePersistMemberIndex();
|
||||||
|
}
|
||||||
updateHudDot();
|
updateHudDot();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user