import {AdapterState, AdapterData} from "./adapter"; import {Message, Attachment, Author} from "./message" import util from "./util" import { TabBarElement } from "./tabbar-element" import { MessageElement } from "./message-element" import { SettingsElement } from "./settings-element" var $ = util.$ var _ = util._ function main() { const settings = _("settings", JSON.parse(localStorage.getItem("settings") ?? "{}")); customElements.define("underbbs-tabbar", TabBarElement); customElements.define("underbbs-message", MessageElement); customElements.define("underbbs-settings", SettingsElement); tabbarInit(settings.adapters?.map((a:any)=>a.nickname) ?? []); registerServiceWorker(); } function tabbarInit(adapters: string[]) { const nav = $("tabbar_injectparent"); if (nav) { nav.innerHTML = ``; } } async function registerServiceWorker() { if ("serviceWorker" in navigator) { try { const registration = await navigator.serviceWorker.register("/serviceWorker.js", { scope: "/", }); if (registration.installing) { console.log("Service worker installing"); } else if (registration.waiting) { console.log("Service worker installed"); } else if (registration.active) { console.log("Service worker active"); } } catch (error) { console.error(`Registration failed with ${error}`); } const registration = await navigator.serviceWorker.ready; (registration as any).sync.register("testdata").then((r:any)=>{console.log("but i will see this!")}); } } main();