More event refactoring work

This commit is contained in:
Zef Hemel
2023-08-27 14:13:18 +02:00
parent 593597454a
commit c3d384330d
13 changed files with 140 additions and 149 deletions
+2
View File
@@ -37,6 +37,7 @@ functions:
name: "Editor: Move Cursor to Position"
clearPageIndex:
path: "./page.ts:clearPageIndex"
env: server
events:
- page:saved
- page:deleted
@@ -46,6 +47,7 @@ functions:
- query:page
parseIndexTextRepublish:
path: "./page.ts:parseIndexTextRepublish"
env: server
events:
- page:index_text
reindexSpaceCommand:
+3 -3
View File
@@ -13,7 +13,7 @@ import {
import { events, mq } from "$sb/plugos-syscall/mod.ts";
import { applyQuery } from "$sb/lib/query.ts";
import { invokeFunction } from "$sb/silverbullet-syscall/system.ts";
import { invoke } from "$sb/silverbullet-syscall/system.ts";
import type { Message } from "$sb/types.ts";
import { sleep } from "../../common/async_util.ts";
import { cacheFileListing } from "../federation/federation.ts";
@@ -135,7 +135,7 @@ export async function reindexSpace() {
console.log("Clearing page index...");
await index.clearPageIndex();
// Executed this way to not have to embed the search plug code here
await invokeFunction("client", "search.clearIndex");
await invoke("search.clearIndex");
const pages = await space.listPages();
// Queue all page names to be indexed
@@ -172,7 +172,7 @@ export async function clearPageIndex(page: string) {
}
export async function parseIndexTextRepublish({ name, text }: IndexEvent) {
// console.log("Reindexing", name);
console.log("Reindexing", name);
await events.dispatchEvent("page:index", {
name,
tree: await markdown.parseMarkdown(text),
+1 -1
View File
@@ -44,7 +44,7 @@ export async function evalDirectiveRenderer(
const result = await (0, eval)(
`(async () => {
function invokeFunction(name, ...args) {
return syscall("system.invokeFunction", "server", name, ...args);
return syscall("system.invoke", name, ...args);
}
return ${replaceTemplateVars(translateJs(expression), pageMeta)};
})()`,
+1
View File
@@ -12,6 +12,7 @@ functions:
searchUnindex:
path: "./search.ts:pageUnindex"
env: client
events:
- page:deleted
searchQueryProvider: