Use "store" syscall to keep index and version state
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { get, set } from "@silverbulletmd/plugos-silverbullet-syscall";
|
||||
import { get, set } from "@plugos/plugos-syscall/store";
|
||||
import { flashNotification } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
|
||||
import {
|
||||
getVersion,
|
||||
@@ -8,22 +8,22 @@ import {
|
||||
export async function editorInit() {
|
||||
let currentVersion = await getVersion();
|
||||
console.log("Running version check", currentVersion);
|
||||
let lastVersion = await get("index", "$silverBulletVersion");
|
||||
let lastVersion = await get("$silverBulletVersion");
|
||||
console.log("Last version", lastVersion);
|
||||
if (lastVersion !== currentVersion) {
|
||||
await flashNotification(
|
||||
"Version update detected, going to reload plugs..."
|
||||
);
|
||||
await set("index", "$spaceIndexed", false);
|
||||
await set("index", "$silverBulletVersion", currentVersion);
|
||||
await set("$spaceIndexed", false);
|
||||
await set("$silverBulletVersion", currentVersion);
|
||||
invokeFunction("client", "updatePlugsCommand");
|
||||
} else {
|
||||
let spaceIndexed = await get("index", "$spaceIndexed");
|
||||
let spaceIndexed = await get("$spaceIndexed");
|
||||
console.log("Space indexed", spaceIndexed);
|
||||
if (!spaceIndexed) {
|
||||
await invokeFunction("client", "reindexSpaceCommand");
|
||||
// Resetting this, because part of the reindex will be to wipe this too
|
||||
await set("index", "$silverBulletVersion", currentVersion);
|
||||
await set("$silverBulletVersion", currentVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user