Skip to content

Build your personal knowledge base with Trilium Notes

added "safe mode" environment variable switch which disables startup scripts and resets tabs

zadame1e185e5dbe2
diff --git a/src/public/app/widgets/note_type.js b/src/public/app/widgets/note_type.js
index 08dc943b05..efcfa84f48 100644
--- a/src/public/app/widgets/note_type.js
+++ b/src/public/app/widgets/note_type.js
@@ -41,6 +41,9 @@ export default class NoteTypeWidget extends TabAwareWidget {
this.$noteTypeDropdown = this.$widget.find(".note-type-dropdown");
this.$noteTypeButton = this.$widget.find(".note-type-button");
this.$noteTypeDesc = this.$widget.find(".note-type-desc");
+
+ this.$widget.on('click', '.dropdown-item',
+ () => this.$widget.find('.dropdown-toggle').dropdown('toggle'));
}
async refreshWithNote(note) {
diff --git a/src/routes/api/script.js b/src/routes/api/script.js
index 53b6ca56c9..5e1492a8d3 100644
--- a/src/routes/api/script.js
+++ b/src/routes/api/script.js
@@ -54,11 +54,21 @@ function getBundlesWithLabel(label, value) {
}
function getStartupBundles() {
- return getBundlesWithLabel("run", "frontendStartup");
+ if (!process.env.TRILIUM_SAFE_MODE) {
+ return getBundlesWithLabel("run", "frontendStartup");
+ }
+ else {
+ return [];
+ }
}
function getWidgetBundles() {
- return getBundlesWithLabel("widget");
+ if (!process.env.TRILIUM_SAFE_MODE) {
+ return getBundlesWithLabel("widget");
+ }
+ else {
+ return [];
+ }
}
function getRelationBundles(req) {
diff --git a/src/services/options_init.js b/src/services/options_init.js
index 02dbc1ee23..7e66f524a0 100644
--- a/src/services/options_init.js
+++ b/src/services/options_init.js
@@ -101,10 +101,10 @@ function initStartupOptions() {
}
}
- if (process.env.TRILIUM_START_NOTE_ID) {
+ if (process.env.TRILIUM_START_NOTE_ID || process.env.TRILIUM_SAFE_MODE) {
optionService.setOption('openTabs', JSON.stringify([
{
- notePath: process.env.TRILIUM_START_NOTE_ID,
+ notePath: process.env.TRILIUM_START_NOTE_ID || 'root',
active: true
}
]));
diff --git a/src/services/scheduler.js b/src/services/scheduler.js
index 083343163b..fffdc61525 100644
--- a/src/services/scheduler.js
+++ b/src/services/scheduler.js
@@ -22,9 +22,11 @@ function runNotesWithLabel(runAttrValue) {
}
sqlInit.dbReady.then(() => {
- setTimeout(cls.wrap(() => runNotesWithLabel('backendStartup')), 10 * 1000);
+ if (!process.env.TRILIUM_SAFE_MODE) {
+ setTimeout(cls.wrap(() => runNotesWithLabel('backendStartup')), 10 * 1000);
- setInterval(cls.wrap(() => runNotesWithLabel('hourly')), 3600 * 1000);
+ setInterval(cls.wrap(() => runNotesWithLabel('hourly')), 3600 * 1000);
- setInterval(cls.wrap(() => runNotesWithLabel('daily')), 24 * 3600 * 1000);
+ setInterval(cls.wrap(() => runNotesWithLabel('daily')), 24 * 3600 * 1000);
+ }
});
diff --git a/src/services/script.js b/src/services/script.js
index eb9c92f83e..6f34b9eaf6 100644
--- a/src/services/script.js
+++ b/src/services/script.js
@@ -1,4 +1,3 @@
-const sql = require('./sql');
const ScriptContext = require('./script_context');
const repository = require('./repository');
const cls = require('./cls');