From 0d5160eba120b5a5f56dfbfb53e8120176916cd1 Mon Sep 17 00:00:00 2001 From: linonetwo Date: Mon, 4 Nov 2024 14:48:41 +0800 Subject: [PATCH] fix: lazy load tiddler saved as empty one fixes #68 --- .../file-system-syncadaptor.ts | 4 ++++ src/services/WikiStorageService/index.ts | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/plugins/src/expo-file-system-syncadaptor/file-system-syncadaptor.ts b/plugins/src/expo-file-system-syncadaptor/file-system-syncadaptor.ts index f44bfa1..82e64bd 100644 --- a/plugins/src/expo-file-system-syncadaptor/file-system-syncadaptor.ts +++ b/plugins/src/expo-file-system-syncadaptor/file-system-syncadaptor.ts @@ -235,6 +235,10 @@ class TidGiMobileFileSystemSyncAdaptor { return; } try { + // Similar to https://github.com/TiddlyWiki/TiddlyWiki5/blob/master/core/modules/server/routes/put-tiddler.js#L36 but we just stop saving, and wait for lazy-load on client to complete, and let client to save again later. + if (tiddler.fields._is_skinny) { + return; + } const title = tiddler.fields.title; if (this.tiddlersToNotSave.includes(title)) { this.logger.log(`Ignore saveTiddler ${title}, config in TiddlersToNotSave`); diff --git a/src/services/WikiStorageService/index.ts b/src/services/WikiStorageService/index.ts index b7b7a55..d7998a2 100644 --- a/src/services/WikiStorageService/index.ts +++ b/src/services/WikiStorageService/index.ts @@ -25,9 +25,9 @@ import { getFullSaveTiddlers } from './ignoredTiddler'; * All methods must be async. */ export class WikiStorageService { - #workspace: IWikiWorkspace; - #configStore = useConfigStore; - #serverStore = useServerStore; + readonly #workspace: IWikiWorkspace; + readonly #configStore = useConfigStore; + readonly #serverStore = useServerStore; constructor(workspace: IWikiWorkspace) { this.#workspace = workspace; @@ -50,6 +50,7 @@ export class WikiStorageService { */ async saveTiddler(title: string, fields: ITiddlerFieldsParam): Promise { try { + /** Tiddlers that should save to SQLite as full tiddlers. Like plugins that starts with `$:/` */ const saveFullTiddler = getFullSaveTiddlers(title).includes(title); const { text, title: _, ...fieldsObjectToSave } = fields as (ITiddlerFieldsParam & { text?: string; title: string }); const changeCount = '0'; // this.wikiInstance.wiki.getChangeCount(title).toString();