loadFieldCache function
Last updated: 2026-03-01T23:25:47.136Z
Location
Metrics
LOC: 40
Complexity: 8
Params: 0
Signature
loadFieldCache(): : Promise<void>
Source Code
async function loadFieldCache(): Promise<void> {
const cache = (await chrome.runtime.sendMessage({
type: "GET_FIELD_CACHE",
})) as FieldDetectionCacheEntry[] | null;
const list = document.getElementById("cache-list");
if (!list) return;
list.innerHTML = "";
if (!Array.isArray(cache) || cache.length === 0) {
list.innerHTML = `<div class="empty">${t("noCacheEntries")}</div>`;
return;
}
const sorted = [...cache].sort((a, b) => b.updatedAt - a.updatedAt);
for (const entry of sorted) {
const item = document.createElement("div");
item.className = "rule-item";
item.innerHTML = `
<div class="rule-info">
<strong>${escapeHtml(entry.hostname || entry.origin || entry.url)}</strong>
<span class="rule-selector">${escapeHtml(entry.path || entry.url)}</span>
<span class="badge">${t("cacheFieldsCount", [String(entry.count)])}</span>
<span class="rule-priority">${t("updatedAtLabel")}: ${new Date(entry.updatedAt).toLocaleString()}</span>
</div>
<button class="btn btn-sm btn-delete" data-cache-url="${escapeHtml(entry.url)}">${t("btnDelete")}</button>
`;
item.querySelector(".btn-delete")?.addEventListener("click", async () => {
await chrome.runtime.sendMessage({
type: "DELETE_FIELD_CACHE",
payload: entry.url,
});
await loadFieldCache();
showToast(t("toastCacheEntryRemoved"));
});
list.appendChild(item);
}
}
Dependencies (Outgoing)
| Target | Type |
|---|---|
| loadFieldCache | calls |
| click | dynamic_call |
Impact (Incoming)
| Source | Type |
|---|---|
| loadFieldCache | calls |
| bindCacheEvents | calls |
| initCacheTab | calls |