mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
refactored options_init to options on frontend
This commit is contained in:
parent
f9abea83f3
commit
9622b046e0
6
package-lock.json
generated
6
package-lock.json
generated
@ -3127,9 +3127,9 @@
|
|||||||
"integrity": "sha512-PcW2a0tyTuPHz3tWyYqtK6r1fZ3gp+3Sop8Ph+ZYN81Ob5rwmbHEzaqs10N3BEsaGTkh/ooniXK+WwszGlc2+Q=="
|
"integrity": "sha512-PcW2a0tyTuPHz3tWyYqtK6r1fZ3gp+3Sop8Ph+ZYN81Ob5rwmbHEzaqs10N3BEsaGTkh/ooniXK+WwszGlc2+Q=="
|
||||||
},
|
},
|
||||||
"electron": {
|
"electron": {
|
||||||
"version": "6.0.3",
|
"version": "6.0.4",
|
||||||
"resolved": "https://registry.npmjs.org/electron/-/electron-6.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/electron/-/electron-6.0.4.tgz",
|
||||||
"integrity": "sha512-+AFB075WVf4LBR4bdPlkGn/jYQOZ7kC4GpZBeZ3/Fj5SCoFP51TAA5HuPWdMF2KQWjpxx/18jDGqMTYWhIRsEw==",
|
"integrity": "sha512-zrPi36etADOAjxnVX6TxRNKSWaBscMLd9S7AB+qISzI0dnYIDKycHpc2mB+5QWBd/8cR4m/1NLNTqNhX5KKGFg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@types/node": "^10.12.18",
|
"@types/node": "^10.12.18",
|
||||||
|
@ -77,7 +77,7 @@
|
|||||||
"xml2js": "0.4.19"
|
"xml2js": "0.4.19"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"electron": "6.0.3",
|
"electron": "6.0.4",
|
||||||
"electron-builder": "21.2.0",
|
"electron-builder": "21.2.0",
|
||||||
"electron-compile": "6.4.4",
|
"electron-compile": "6.4.4",
|
||||||
"electron-installer-debian": "2.0.0",
|
"electron-installer-debian": "2.0.0",
|
||||||
|
@ -2,7 +2,7 @@ import server from "../../services/server.js";
|
|||||||
import utils from "../../services/utils.js";
|
import utils from "../../services/utils.js";
|
||||||
import cssLoader from "../../services/css_loader.js";
|
import cssLoader from "../../services/css_loader.js";
|
||||||
import zoomService from "../../services/zoom.js";
|
import zoomService from "../../services/zoom.js";
|
||||||
import optionsInit from "../../services/options_init.js";
|
import optionsService from "../../services/options.js";
|
||||||
|
|
||||||
export default class ApperanceOptions {
|
export default class ApperanceOptions {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -45,7 +45,7 @@ export default class ApperanceOptions {
|
|||||||
const hideTabRowForOneTab = this.$oneTabDisplaySelect.val() === 'hide' ? 'true' : 'false';
|
const hideTabRowForOneTab = this.$oneTabDisplaySelect.val() === 'hide' ? 'true' : 'false';
|
||||||
|
|
||||||
server.put('options/hideTabRowForOneTab/' + hideTabRowForOneTab)
|
server.put('options/hideTabRowForOneTab/' + hideTabRowForOneTab)
|
||||||
.then(optionsInit.reloadOptions);
|
.then(optionsService.reloadOptions);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$leftPaneMinWidth.change(async () => {
|
this.$leftPaneMinWidth.change(async () => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import optionsInit from "../../services/options_init.js";
|
import optionsService from "../../services/options.js";
|
||||||
import server from "../../services/server.js";
|
import server from "../../services/server.js";
|
||||||
import infoService from "../../services/info.js";
|
import infoService from "../../services/info.js";
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ export default class ProtectedSessionOptions {
|
|||||||
const protectedSessionTimeout = this.$protectedSessionTimeout.val();
|
const protectedSessionTimeout = this.$protectedSessionTimeout.val();
|
||||||
|
|
||||||
server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
|
server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
|
||||||
optionsInit.reloadOptions();
|
optionsService.reloadOptions();
|
||||||
|
|
||||||
infoService.showMessage("Options change have been saved.");
|
infoService.showMessage("Options change have been saved.");
|
||||||
});
|
});
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import libraryLoader from "../../services/library_loader.js";
|
import libraryLoader from "../../services/library_loader.js";
|
||||||
import server from "../../services/server.js";
|
import server from "../../services/server.js";
|
||||||
import optionsInit from "../../services/options_init.js";
|
import optionsService from "../../services/options.js";
|
||||||
|
|
||||||
export default class SidebarOptions {
|
export default class SidebarOptions {
|
||||||
constructor() {
|
constructor() {
|
||||||
@ -28,7 +28,7 @@ export default class SidebarOptions {
|
|||||||
|
|
||||||
await server.put('options/showSidebarInNewTab/' + flag);
|
await server.put('options/showSidebarInNewTab/' + flag);
|
||||||
|
|
||||||
optionsInit.reloadOptions();
|
optionsService.reloadOptions();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ export default class SidebarOptions {
|
|||||||
|
|
||||||
await server.put('options', opts);
|
await server.put('options', opts);
|
||||||
|
|
||||||
optionsInit.reloadOptions();
|
optionsService.reloadOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
parseJsonSafely(str) {
|
parseJsonSafely(str) {
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import optionsInit from './options_init.js';
|
import optionsService from './options.js';
|
||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
import tree from "./tree.js";
|
import tree from "./tree.js";
|
||||||
import noteDetailService from "./note_detail.js";
|
import noteDetailService from "./note_detail.js";
|
||||||
|
|
||||||
let hoistedNoteId;
|
let hoistedNoteId;
|
||||||
|
|
||||||
optionsInit.waitForOptions().then(options => {
|
optionsService.waitForOptions().then(options => {
|
||||||
hoistedNoteId = options.get('hoistedNoteId');
|
hoistedNoteId = options.get('hoistedNoteId');
|
||||||
});
|
});
|
||||||
|
|
||||||
async function getHoistedNoteId() {
|
async function getHoistedNoteId() {
|
||||||
await optionsInit.waitForOptions();
|
await optionsService.waitForOptions();
|
||||||
|
|
||||||
return hoistedNoteId;
|
return hoistedNoteId;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ function NoteTypeContext(ctx) {
|
|||||||
self.$renderButton.toggle(ctx.note.type === 'render');
|
self.$renderButton.toggle(ctx.note.type === 'render');
|
||||||
};
|
};
|
||||||
|
|
||||||
ko.applyBindings(this, ctx.$tabContent.find('.note-type-wrapper')[0])
|
ko.applyBindings(this, ctx.$tabContent.find('.note-type-wrapper')[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import utils from "./utils.js";
|
import utils from "./utils.js";
|
||||||
import optionsInitService from './options_init.js';
|
import optionsService from './options.js';
|
||||||
|
|
||||||
const PROTECTED_SESSION_ID_KEY = 'protectedSessionId';
|
const PROTECTED_SESSION_ID_KEY = 'protectedSessionId';
|
||||||
|
|
||||||
let lastProtectedSessionOperationDate = null;
|
let lastProtectedSessionOperationDate = null;
|
||||||
let protectedSessionTimeout = null;
|
let protectedSessionTimeout = null;
|
||||||
|
|
||||||
optionsInitService.addLoadListener(options => setProtectedSessionTimeout(options.getInt('protectedSessionTimeout')));
|
optionsService.addLoadListener(options => setProtectedSessionTimeout(options.getInt('protectedSessionTimeout')));
|
||||||
|
|
||||||
setInterval(() => {
|
setInterval(() => {
|
||||||
if (lastProtectedSessionOperationDate !== null && Date.now() - lastProtectedSessionOperationDate.getTime() > protectedSessionTimeout * 1000) {
|
if (lastProtectedSessionOperationDate !== null && Date.now() - lastProtectedSessionOperationDate.getTime() > protectedSessionTimeout * 1000) {
|
||||||
|
@ -17,7 +17,7 @@ import noteDetailRender from "./note_detail_render.js";
|
|||||||
import noteDetailRelationMap from "./note_detail_relation_map.js";
|
import noteDetailRelationMap from "./note_detail_relation_map.js";
|
||||||
import noteDetailProtectedSession from "./note_detail_protected_session.js";
|
import noteDetailProtectedSession from "./note_detail_protected_session.js";
|
||||||
import protectedSessionService from "./protected_session.js";
|
import protectedSessionService from "./protected_session.js";
|
||||||
import optionsInitService from "./options_init.js";
|
import optionsService from "./options.js";
|
||||||
import linkService from "./link.js";
|
import linkService from "./link.js";
|
||||||
import Sidebar from "./sidebar.js";
|
import Sidebar from "./sidebar.js";
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ const componentClasses = {
|
|||||||
|
|
||||||
let showSidebarInNewTab = true;
|
let showSidebarInNewTab = true;
|
||||||
|
|
||||||
optionsInitService.addLoadListener(options => {
|
optionsService.addLoadListener(options => {
|
||||||
showSidebarInNewTab = options.is('showSidebarInNewTab');
|
showSidebarInNewTab = options.is('showSidebarInNewTab');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
File diff suppressed because one or more lines are too long
@ -13,7 +13,7 @@ import treeKeyBindings from "./tree_keybindings.js";
|
|||||||
import Branch from '../entities/branch.js';
|
import Branch from '../entities/branch.js';
|
||||||
import NoteShort from '../entities/note_short.js';
|
import NoteShort from '../entities/note_short.js';
|
||||||
import hoistedNoteService from '../services/hoisted_note.js';
|
import hoistedNoteService from '../services/hoisted_note.js';
|
||||||
import optionsInit from "../services/options_init.js";
|
import optionsService from "../services/options.js";
|
||||||
import TreeContextMenu from "./tree_context_menu.js";
|
import TreeContextMenu from "./tree_context_menu.js";
|
||||||
import bundle from "./bundle.js";
|
import bundle from "./bundle.js";
|
||||||
|
|
||||||
@ -331,7 +331,7 @@ async function treeInitialized() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const options = await optionsInit.waitForOptions();
|
const options = await optionsService.waitForOptions();
|
||||||
|
|
||||||
const openTabs = options.getJson('openTabs') || [];
|
const openTabs = options.getJson('openTabs') || [];
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
import utils from "./utils.js";
|
import utils from "./utils.js";
|
||||||
import optionsInitService from "./options_init.js";
|
import optionsService from "./options.js";
|
||||||
|
|
||||||
const MIN_ZOOM = 0.5;
|
const MIN_ZOOM = 0.5;
|
||||||
const MAX_ZOOM = 2.0;
|
const MAX_ZOOM = 2.0;
|
||||||
@ -40,7 +40,7 @@ function getCurrentZoom() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
optionsInitService.addLoadListener(options => setZoomFactor(options.getFloat('zoomFactor')))
|
optionsService.addLoadListener(options => setZoomFactor(options.getFloat('zoomFactor')))
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import optionsInit from "../services/options_init.js";
|
import optionsService from "../services/options.js";
|
||||||
|
|
||||||
const WIDGET_TPL = `
|
const WIDGET_TPL = `
|
||||||
<div class="card widget">
|
<div class="card widget">
|
||||||
@ -84,7 +84,7 @@ class StandardWidget {
|
|||||||
async doRenderBody() {}
|
async doRenderBody() {}
|
||||||
|
|
||||||
async isEnabled() {
|
async isEnabled() {
|
||||||
const option = await optionsInit.getJsonOption(this.widgetName + 'Widget');
|
const option = await optionsService.getJsonOption(this.widgetName + 'Widget');
|
||||||
|
|
||||||
return option ? option.enabled : true;
|
return option ? option.enabled : true;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user