forked from Blendman974/faceclaw
Add glanceboard widget for T3code
This commit is contained in:
1 parent
043e5e74ce
commit
49a49d68ce
12 files changed
+453
-34
No files matched your search
@@ -1,4 +1,13 @@
|
||||
import { launchWorkerAppWindow, type AppDefinition } from "../app-definition";
|
||||
import { onSettingsStoreChanged } from "../../native/settings-store";
|
||||
import { hasT3BackgroundWork } from "./background";
|
||||
import { T3_ENVIRONMENTS_KEY } from "./t3-environments";
|
||||
|
||||
/** The one place the worker is constructed (string-literal path for the webpack worker loader). */
|
||||
const createWorker = () => new Worker("./t3code-app.worker");
|
||||
|
||||
/** The boot hook's settings listener; replaced if a controller boots again. */
|
||||
let stopWatchingSettings: (() => void) | null = null;
|
||||
|
||||
const t3codeApp: AppDefinition = {
|
||||
appId: "t3code",
|
||||
@@ -6,12 +15,28 @@ const t3codeApp: AppDefinition = {
|
||||
icon: "t3code",
|
||||
launch: (ctx) =>
|
||||
launchWorkerAppWindow(ctx, {
|
||||
createWorker: () => new Worker("./t3code-app.worker"),
|
||||
createWorker,
|
||||
windowId: "t3code:main",
|
||||
title: "T3 Code",
|
||||
iconLetter: "T3",
|
||||
icon: "t3code",
|
||||
}),
|
||||
/**
|
||||
* The Glanceboard's T3 Code widget shows what this app's worker knows, so
|
||||
* start the worker (windowless) whenever the widget is in use: at startup,
|
||||
* and when the widget, the board, or the paired environments change. The
|
||||
* worker reports idle by itself once nothing needs it.
|
||||
*/
|
||||
boot: (ctx) => {
|
||||
const ensureWorker = () => {
|
||||
if (hasT3BackgroundWork()) ctx.ensureWorkerHost(createWorker);
|
||||
};
|
||||
ensureWorker();
|
||||
stopWatchingSettings?.();
|
||||
stopWatchingSettings = onSettingsStoreChanged((key) => {
|
||||
if (key.startsWith("glanceboard.") || key === T3_ENVIRONMENTS_KEY) ensureWorker();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export default t3codeApp;
|
||||
Reference in new issue
Block a user