TiddlyWiki5 icon indicating copy to clipboard operation
TiddlyWiki5 copied to clipboard

Add option for syncer module to not always load all skinny tiddlers

Open qiushihe opened this issue 3 years ago • 4 comments

This PR is meant to address this issue: https://github.com/Jermolene/TiddlyWiki5/issues/4598

Option for syncer module to not always immediately fetch all skinny tiddlers

Currently, whenever some skinny tiddlers are fetched via syncadaptor.getSkinnyTiddlers, the syncer module will immediately load the fat version of those tiddlers, regardless if any of those tiddlers are viewed/loaded/needed by the user or not.

As mentioned in the issue referenced above, this behaviour completely defeats the purpose of having skinny tiddlers and lazy loading.

This PR adds a alwaysFetchAllSkinnyTiddlers option to the syncer module that's defaulted to true in order to maintain current default logic.

If alwaysFetchAllSkinnyTiddlers is set to false then the syncer module will no longer immediately fetch all skinny tiddlers, and will instead wait for the lazyLoad event for a particular skinny tiddler to trigger a fetch of the fat version of that tiddler.


With Regarding to Setting the Value of the alwaysFetchAllSkinnyTiddlers Option

Currently the syncer module will attempt to call syncadaptor.getStatus before continuing with fetching skinny tiddlers, in the constructor of the syncer module.

This means that it's important to ensure alwaysFetchAllSkinnyTiddlers is set properly before the syncer module has an opportunities to fetch skinny tiddlers.

This means that a custom syncadaptor module should ensure that:

  • It has a getStatus function
  • That getStatus function do not call its callback before setting $tw.syncer.alwaysFetchAllSkinnyTiddlers = false;

The exact implementation there would depend on the implementation of the custom syncadaptor module. But the idea is that we have to make sure $tw.syncer.alwaysFetchAllSkinnyTiddlers is set to false before the syncer module's skinny tiddlers fetching code can run.


p.s. This PR also updates the "is the tiddler skinny" logic in the syncer module to check for the presence of the _is_skinny field, in addition to checking if the text field is missing or not.

qiushihe avatar Dec 28 '21 23:12 qiushihe

Also, I realized what this means is that if alwaysFetchAllSkinnyTiddlers is set to false, and when the user navigates to a skinny tiddler, they would see a "blank" state for a few seconds before the content pops in... 'cause the content of the skinny tiddler has to be loaded on demand.

I know that's not ideal, but addressing that would also be IMO outside of the scope of this PR, because I'm not sure if it's really the syncer module's responsibility to handler adding a "loading" UI state to tiddlers. Some other internal modules should probably be updated to facilitate that instead.

So for now, navigating to skinny tiddlers will results in some pop-in's, but the wiki can now be leaner without having to fetch literally everything on startup.

qiushihe avatar Dec 28 '21 23:12 qiushihe

@Jermolene @pmario I updated the syntax to ES5 and made additional changes (see https://github.com/Jermolene/TiddlyWiki5/pull/6372#discussion_r776589364 for detail). Please re-review. Thanks!

qiushihe avatar Dec 30 '21 06:12 qiushihe

@qiushihe did you join our QQ group? 946052860

linonetwo avatar May 31 '22 08:05 linonetwo