1
0

Use "store" syscall to keep index and version state

This commit is contained in:
Zef Hemel 2022-07-12 12:30:36 +02:00
parent f0d09a51e6
commit 32e5a3ec94
2 changed files with 10 additions and 7 deletions

View File

@ -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 { flashNotification } from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import { import {
getVersion, getVersion,
@ -8,22 +8,22 @@ import {
export async function editorInit() { export async function editorInit() {
let currentVersion = await getVersion(); let currentVersion = await getVersion();
console.log("Running version check", currentVersion); console.log("Running version check", currentVersion);
let lastVersion = await get("index", "$silverBulletVersion"); let lastVersion = await get("$silverBulletVersion");
console.log("Last version", lastVersion); console.log("Last version", lastVersion);
if (lastVersion !== currentVersion) { if (lastVersion !== currentVersion) {
await flashNotification( await flashNotification(
"Version update detected, going to reload plugs..." "Version update detected, going to reload plugs..."
); );
await set("index", "$spaceIndexed", false); await set("$spaceIndexed", false);
await set("index", "$silverBulletVersion", currentVersion); await set("$silverBulletVersion", currentVersion);
invokeFunction("client", "updatePlugsCommand"); invokeFunction("client", "updatePlugsCommand");
} else { } else {
let spaceIndexed = await get("index", "$spaceIndexed"); let spaceIndexed = await get("$spaceIndexed");
console.log("Space indexed", spaceIndexed); console.log("Space indexed", spaceIndexed);
if (!spaceIndexed) { if (!spaceIndexed) {
await invokeFunction("client", "reindexSpaceCommand"); await invokeFunction("client", "reindexSpaceCommand");
// Resetting this, because part of the reindex will be to wipe this too // Resetting this, because part of the reindex will be to wipe this too
await set("index", "$silverBulletVersion", currentVersion); await set("$silverBulletVersion", currentVersion);
} }
} }
} }

View File

@ -6,6 +6,9 @@ import {
queryPrefix, queryPrefix,
set, set,
} from "@silverbulletmd/plugos-silverbullet-syscall/index"; } from "@silverbulletmd/plugos-silverbullet-syscall/index";
import { set as storeSet } from "@plugos/plugos-syscall/store";
import { import {
flashNotification, flashNotification,
getCurrentPage, getCurrentPage,
@ -189,7 +192,7 @@ async function getBackLinks(pageName: string): Promise<BackLink[]> {
export async function reindexCommand() { export async function reindexCommand() {
await flashNotification("Reindexing..."); await flashNotification("Reindexing...");
await invokeFunction("server", "reindexSpace"); await invokeFunction("server", "reindexSpace");
await set("index", "$spaceIndexed", true); await storeSet("$spaceIndexed", true);
await flashNotification("Reindexing done"); await flashNotification("Reindexing done");
} }