Skip to content

Commit

Permalink
custom widget launchers should not be initialized in safe mode
Browse files Browse the repository at this point in the history
  • Loading branch information
zadam committed Dec 24, 2022
1 parent b13ea72 commit 4c51588
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/public/app/widgets/containers/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export default class LauncherWidget extends BasicWidget {

const launcherType = note.getLabelValue("launcherType");

if (glob.TRILIUM_SAFE_MODE && launcherType === 'customWidget') {
return false;
}

if (launcherType === 'command') {
this.innerWidget = this.initCommandLauncherWidget(note)
.class("launcher-button");
Expand Down
29 changes: 13 additions & 16 deletions src/public/app/widgets/containers/launcher_container.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,19 @@ export default class LauncherContainer extends FlexContainer {
return;
}

await Promise.allSettled(
(await visibleLaunchersRoot.getChildNotes())
.map(async launcherNote => {
try {
const launcherWidget = new LauncherWidget();
const success = await launcherWidget.initLauncher(launcherNote);

if (success) {
this.child(launcherWidget);
}
}
catch (e) {
console.error(e);
}
})
);
for (const launcherNote of await visibleLaunchersRoot.getChildNotes()) {
try {
const launcherWidget = new LauncherWidget();
const success = await launcherWidget.initLauncher(launcherNote);

if (success) {
this.child(launcherWidget);
}
}
catch (e) {
console.error(e);
}
}

this.$widget.empty();
this.renderChildren();
Expand Down
3 changes: 2 additions & 1 deletion src/views/desktop.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
extraHoistedNoteId: '<%= extraHoistedNoteId %>',
isProtectedSessionAvailable: <%= isProtectedSessionAvailable %>,
triliumVersion: "<%= triliumVersion %>",
assetPath: "<%= assetPath %>"
assetPath: "<%= assetPath %>",
TRILIUM_SAFE_MODE: <%= !!process.env.TRILIUM_SAFE_MODE %>
};
</script>

Expand Down
3 changes: 2 additions & 1 deletion src/views/mobile.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@
appCssNoteIds: <%- JSON.stringify(appCssNoteIds) %>,
isProtectedSessionAvailable: <%= isProtectedSessionAvailable %>,
assetPath: "<%= assetPath %>",
isMainWindow: true
isMainWindow: true,
TRILIUM_SAFE_MODE: <%= !!process.env.TRILIUM_SAFE_MODE %>
};
</script>

Expand Down

0 comments on commit 4c51588

Please sign in to comment.