for automatic review

This commit is contained in:
vorotamoroz
2026-06-17 05:51:01 +01:00
parent 497fd04081
commit 2d5cdccf7d
24 changed files with 123 additions and 85 deletions
+11 -10
View File
@@ -1,11 +1,12 @@
import { LiveSyncWebApp } from "./main";
import { VaultHistoryStore, type VaultHistoryItem } from "./vaultSelector";
import { compatGlobal, _activeDocument } from "@lib/common/coreEnvFunctions.ts";
const historyStore = new VaultHistoryStore();
let app: LiveSyncWebApp | null = null;
function getRequiredElement<T extends HTMLElement>(id: string): T {
const element = document.getElementById(id);
const element = _activeDocument.getElementById(id);
if (!element) {
throw new Error(`Missing element: #${id}`);
}
@@ -22,7 +23,7 @@ function setBusyState(isBusy: boolean): void {
const pickNewBtn = getRequiredElement<HTMLButtonElement>("pick-new-vault");
pickNewBtn.disabled = isBusy;
const historyButtons = document.querySelectorAll<HTMLButtonElement>(".vault-item button");
const historyButtons = _activeDocument.querySelectorAll<HTMLButtonElement>(".vault-item button");
historyButtons.forEach((button) => {
button.disabled = isBusy;
});
@@ -45,24 +46,24 @@ async function renderHistoryList(): Promise<VaultHistoryItem[]> {
emptyEl.classList.toggle("is-hidden", items.length > 0);
for (const item of items) {
const row = document.createElement("div");
const row = _activeDocument.createElement("div");
row.className = "vault-item";
const info = document.createElement("div");
const info = _activeDocument.createElement("div");
info.className = "vault-item-info";
const name = document.createElement("div");
const name = _activeDocument.createElement("div");
name.className = "vault-item-name";
name.textContent = item.name;
const meta = document.createElement("div");
const meta = _activeDocument.createElement("div");
meta.className = "vault-item-meta";
const label = item.id === lastUsedId ? "Last used" : "Used";
meta.textContent = `${label}: ${formatLastUsed(item.lastUsedAt)}`;
info.append(name, meta);
const useButton = document.createElement("button");
const useButton = _activeDocument.createElement("button");
useButton.type = "button";
useButton.textContent = "Use this vault";
useButton.addEventListener("click", () => {
@@ -120,7 +121,7 @@ async function initializeVaultSelector(): Promise<void> {
await renderHistoryList();
}
window.addEventListener("load", async () => {
compatGlobal.addEventListener("load", async () => {
try {
await initializeVaultSelector();
} catch (error) {
@@ -129,11 +130,11 @@ window.addEventListener("load", async () => {
}
});
window.addEventListener("beforeunload", () => {
compatGlobal.addEventListener("beforeunload", () => {
void app?.shutdown();
});
(window as any).livesyncApp = {
(compatGlobal as any).livesyncApp = {
getApp: () => app,
historyStore,
};