mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-02 12:19:11 +00:00
Allow background actions to be scoped by platform
This commit is contained in:
parent
efcd23993e
commit
546e438943
@ -90,15 +90,27 @@ function BackgroundActionTracker(options) {
|
||||
fnProcess: function(changes) {
|
||||
if(self.hasChanged) {
|
||||
self.hasChanged = false;
|
||||
self.wiki.invokeActionString(
|
||||
self.actions,
|
||||
null,
|
||||
{
|
||||
title: self.title
|
||||
},{
|
||||
parentWidget: $tw.rootWidget
|
||||
console.log("Processing background action",self.title);
|
||||
var tiddler = self.wiki.getTiddler(self.title),
|
||||
doActions = true;
|
||||
if(tiddler && tiddler.fields.platforms) {
|
||||
doActions = false;
|
||||
var platforms = $tw.utils.parseStringArray(tiddler.fields.platforms);
|
||||
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
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,5 +1,6 @@
|
||||
title: SampleBackgroundAction: Dark Mode
|
||||
tags: $:/tags/BackgroundAction $:/tags/StartupAction
|
||||
tags: $:/tags/BackgroundAction $:/tags/StartupAction/Browser
|
||||
platforms: browser
|
||||
track-filter: [{$:/info/browser/darkmode}]
|
||||
|
||||
<%if [{$:/info/browser/darkmode}match[no]] %>
|
||||
|
@ -1,6 +1,8 @@
|
||||
title: $:/core/background-actions/AutoCompilePalette
|
||||
tags: $:/tags/BackgroundAction $:/tags/StartupAction
|
||||
track-filter: [[$:/palette]] +[changecount[]]
|
||||
platforms: browser
|
||||
track-filter: [[$:/palette]] +[changecount[]]
|
||||
|
||||
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||
<$action-log $message="AutoCompilePalette" darkmode={{$:/info/browser/darkmode}} palette={{$:/palette}}/>
|
||||
<<actions-recompile-current-palette>>
|
||||
|
Loading…
Reference in New Issue
Block a user