1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-02-08 23:20:03 +00:00

Allow background actions to be scoped by platform

This commit is contained in:
Jeremy Ruston 2025-01-27 21:45:17 +00:00
parent efcd23993e
commit 546e438943
3 changed files with 25 additions and 10 deletions

View File

@ -90,15 +90,27 @@ function BackgroundActionTracker(options) {
fnProcess: function(changes) { fnProcess: function(changes) {
if(self.hasChanged) { if(self.hasChanged) {
self.hasChanged = false; self.hasChanged = false;
self.wiki.invokeActionString( console.log("Processing background action",self.title);
self.actions, var tiddler = self.wiki.getTiddler(self.title),
null, doActions = true;
{ if(tiddler && tiddler.fields.platforms) {
title: self.title doActions = false;
},{ var platforms = $tw.utils.parseStringArray(tiddler.fields.platforms);
parentWidget: $tw.rootWidget if(($tw.browser && platforms.indexOf("browser") !== -1) || ($tw.node && platforms.indexOf("node") !== -1)) {
doActions = true;
} }
); }
if(doActions) {
self.wiki.invokeActionString(
self.actions,
null,
{
title: self.title
},{
parentWidget: $tw.rootWidget
}
);
}
} }
} }
}); });

View File

@ -1,5 +1,6 @@
title: SampleBackgroundAction: Dark Mode title: SampleBackgroundAction: Dark Mode
tags: $:/tags/BackgroundAction $:/tags/StartupAction tags: $:/tags/BackgroundAction $:/tags/StartupAction/Browser
platforms: browser
track-filter: [{$:/info/browser/darkmode}] track-filter: [{$:/info/browser/darkmode}]
<%if [{$:/info/browser/darkmode}match[no]] %> <%if [{$:/info/browser/darkmode}match[no]] %>

View File

@ -1,6 +1,8 @@
title: $:/core/background-actions/AutoCompilePalette title: $:/core/background-actions/AutoCompilePalette
tags: $:/tags/BackgroundAction $:/tags/StartupAction tags: $:/tags/BackgroundAction $:/tags/StartupAction
track-filter: [[$:/palette]] +[changecount[]] platforms: browser
track-filter: [[$:/palette]] +[changecount[]]
\import [subfilter{$:/core/config/GlobalImportFilter}] \import [subfilter{$:/core/config/GlobalImportFilter}]
<$action-log $message="AutoCompilePalette" darkmode={{$:/info/browser/darkmode}} palette={{$:/palette}}/>
<<actions-recompile-current-palette>> <<actions-recompile-current-palette>>