1
0
silverbullet/packages/plugs/core/editor.ts

31 lines
1.1 KiB
TypeScript
Raw Normal View History

import { get, set } from "@plugos/plugos-syscall/store";
2022-07-11 07:08:22 +00:00
import { flashNotification } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import {
getVersion,
invokeFunction,
} from "@silverbulletmd/plugos-silverbullet-syscall/system";
export async function editorInit() {
let currentVersion = await getVersion();
console.log("Running version check", currentVersion);
let lastVersion = await get("$silverBulletVersion");
2022-07-11 07:08:22 +00:00
console.log("Last version", lastVersion);
if (lastVersion !== currentVersion) {
await flashNotification(
"Version update detected, going to reload plugs..."
);
await set("$spaceIndexed", false);
await set("$silverBulletVersion", currentVersion);
2022-07-11 07:08:22 +00:00
invokeFunction("client", "updatePlugsCommand");
} else {
let spaceIndexed = await get("$spaceIndexed");
2022-07-11 07:08:22 +00:00
console.log("Space indexed", spaceIndexed);
if (!spaceIndexed) {
2022-08-01 16:27:50 +00:00
await set("$spaceIndexed", true);
2022-07-11 07:08:22 +00:00
await invokeFunction("client", "reindexSpaceCommand");
// Resetting this, because part of the reindex will be to wipe this too
await set("$silverBulletVersion", currentVersion);
2022-07-11 07:08:22 +00:00
}
}
}