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

This commit is contained in:
zadam 2021-01-15 20:12:14 +01:00
parent e06c5703ee
commit e1e185e5db
5 changed files with 22 additions and 8 deletions

View File

@ -41,6 +41,9 @@ export default class NoteTypeWidget extends TabAwareWidget {
this.$noteTypeDropdown = this.$widget.find(".note-type-dropdown"); this.$noteTypeDropdown = this.$widget.find(".note-type-dropdown");
this.$noteTypeButton = this.$widget.find(".note-type-button"); this.$noteTypeButton = this.$widget.find(".note-type-button");
this.$noteTypeDesc = this.$widget.find(".note-type-desc"); this.$noteTypeDesc = this.$widget.find(".note-type-desc");
this.$widget.on('click', '.dropdown-item',
() => this.$widget.find('.dropdown-toggle').dropdown('toggle'));
} }
async refreshWithNote(note) { async refreshWithNote(note) {

View File

@ -54,11 +54,21 @@ function getBundlesWithLabel(label, value) {
} }
function getStartupBundles() { function getStartupBundles() {
return getBundlesWithLabel("run", "frontendStartup"); if (!process.env.TRILIUM_SAFE_MODE) {
return getBundlesWithLabel("run", "frontendStartup");
}
else {
return [];
}
} }
function getWidgetBundles() { function getWidgetBundles() {
return getBundlesWithLabel("widget"); if (!process.env.TRILIUM_SAFE_MODE) {
return getBundlesWithLabel("widget");
}
else {
return [];
}
} }
function getRelationBundles(req) { function getRelationBundles(req) {

View File

@ -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([ optionService.setOption('openTabs', JSON.stringify([
{ {
notePath: process.env.TRILIUM_START_NOTE_ID, notePath: process.env.TRILIUM_START_NOTE_ID || 'root',
active: true active: true
} }
])); ]));

View File

@ -22,9 +22,11 @@ function runNotesWithLabel(runAttrValue) {
} }
sqlInit.dbReady.then(() => { 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);
}
}); });

View File

@ -1,4 +1,3 @@
const sql = require('./sql');
const ScriptContext = require('./script_context'); const ScriptContext = require('./script_context');
const repository = require('./repository'); const repository = require('./repository');
const cls = require('./cls'); const cls = require('./cls');