This commit is contained in:
Zef Hemel
2022-08-01 18:27:50 +02:00
parent 538ae95dc4
commit b29b175b40
12 changed files with 35 additions and 29 deletions
+1
View File
@@ -21,6 +21,7 @@ export async function editorInit() {
let spaceIndexed = await get("$spaceIndexed");
console.log("Space indexed", spaceIndexed);
if (!spaceIndexed) {
await set("$spaceIndexed", true);
await invokeFunction("client", "reindexSpaceCommand");
// Resetting this, because part of the reindex will be to wipe this too
await set("$silverBulletVersion", currentVersion);
+5 -1
View File
@@ -2,6 +2,7 @@ import {
flashNotification,
getText,
} from "@silverbulletmd/plugos-silverbullet-syscall/editor";
import { listPages } from "@silverbulletmd/plugos-silverbullet-syscall/space";
function countWords(str: string): number {
const matches = str.match(/[\w\d\'-]+/gi);
@@ -15,7 +16,10 @@ function readingTime(wordCount: number): number {
export async function statsCommand() {
const text = await getText();
const allPages = await listPages();
const wordCount = countWords(text);
const time = readingTime(wordCount);
await flashNotification(`${wordCount} words, ${time} minutes to read.`);
await flashNotification(
`${wordCount} words; ${time} minutes read; ${allPages.length} total pages in space.`
);
}