refactored options_init to options on frontend

This commit is contained in:
zadam 2019-08-25 17:36:13 +02:00
parent f9abea83f3
commit 9622b046e0
14 changed files with 27 additions and 27 deletions

6
package-lock.json generated
View File

@ -3127,9 +3127,9 @@
"integrity": "sha512-PcW2a0tyTuPHz3tWyYqtK6r1fZ3gp+3Sop8Ph+ZYN81Ob5rwmbHEzaqs10N3BEsaGTkh/ooniXK+WwszGlc2+Q=="
},
"electron": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/electron/-/electron-6.0.3.tgz",
"integrity": "sha512-+AFB075WVf4LBR4bdPlkGn/jYQOZ7kC4GpZBeZ3/Fj5SCoFP51TAA5HuPWdMF2KQWjpxx/18jDGqMTYWhIRsEw==",
"version": "6.0.4",
"resolved": "https://registry.npmjs.org/electron/-/electron-6.0.4.tgz",
"integrity": "sha512-zrPi36etADOAjxnVX6TxRNKSWaBscMLd9S7AB+qISzI0dnYIDKycHpc2mB+5QWBd/8cR4m/1NLNTqNhX5KKGFg==",
"dev": true,
"requires": {
"@types/node": "^10.12.18",

View File

@ -77,7 +77,7 @@
"xml2js": "0.4.19"
},
"devDependencies": {
"electron": "6.0.3",
"electron": "6.0.4",
"electron-builder": "21.2.0",
"electron-compile": "6.4.4",
"electron-installer-debian": "2.0.0",

View File

@ -2,7 +2,7 @@ import server from "../../services/server.js";
import utils from "../../services/utils.js";
import cssLoader from "../../services/css_loader.js";
import zoomService from "../../services/zoom.js";
import optionsInit from "../../services/options_init.js";
import optionsService from "../../services/options.js";
export default class ApperanceOptions {
constructor() {
@ -45,7 +45,7 @@ export default class ApperanceOptions {
const hideTabRowForOneTab = this.$oneTabDisplaySelect.val() === 'hide' ? 'true' : 'false';
server.put('options/hideTabRowForOneTab/' + hideTabRowForOneTab)
.then(optionsInit.reloadOptions);
.then(optionsService.reloadOptions);
});
this.$leftPaneMinWidth.change(async () => {

View File

@ -1,4 +1,4 @@
import optionsInit from "../../services/options_init.js";
import optionsService from "../../services/options.js";
import server from "../../services/server.js";
import infoService from "../../services/info.js";
@ -18,7 +18,7 @@ export default class ProtectedSessionOptions {
const protectedSessionTimeout = this.$protectedSessionTimeout.val();
server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
optionsInit.reloadOptions();
optionsService.reloadOptions();
infoService.showMessage("Options change have been saved.");
});

View File

@ -1,6 +1,6 @@
import libraryLoader from "../../services/library_loader.js";
import server from "../../services/server.js";
import optionsInit from "../../services/options_init.js";
import optionsService from "../../services/options.js";
export default class SidebarOptions {
constructor() {
@ -28,7 +28,7 @@ export default class SidebarOptions {
await server.put('options/showSidebarInNewTab/' + flag);
optionsInit.reloadOptions();
optionsService.reloadOptions();
});
}
@ -117,7 +117,7 @@ export default class SidebarOptions {
await server.put('options', opts);
optionsInit.reloadOptions();
optionsService.reloadOptions();
}
parseJsonSafely(str) {

View File

@ -1,16 +1,16 @@
import optionsInit from './options_init.js';
import optionsService from './options.js';
import server from "./server.js";
import tree from "./tree.js";
import noteDetailService from "./note_detail.js";
let hoistedNoteId;
optionsInit.waitForOptions().then(options => {
optionsService.waitForOptions().then(options => {
hoistedNoteId = options.get('hoistedNoteId');
});
async function getHoistedNoteId() {
await optionsInit.waitForOptions();
await optionsService.waitForOptions();
return hoistedNoteId;
}

View File

@ -181,7 +181,7 @@ function NoteTypeContext(ctx) {
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 {

View File

@ -1,12 +1,12 @@
import utils from "./utils.js";
import optionsInitService from './options_init.js';
import optionsService from './options.js';
const PROTECTED_SESSION_ID_KEY = 'protectedSessionId';
let lastProtectedSessionOperationDate = null;
let protectedSessionTimeout = null;
optionsInitService.addLoadListener(options => setProtectedSessionTimeout(options.getInt('protectedSessionTimeout')));
optionsService.addLoadListener(options => setProtectedSessionTimeout(options.getInt('protectedSessionTimeout')));
setInterval(() => {
if (lastProtectedSessionOperationDate !== null && Date.now() - lastProtectedSessionOperationDate.getTime() > protectedSessionTimeout * 1000) {

View File

@ -17,7 +17,7 @@ import noteDetailRender from "./note_detail_render.js";
import noteDetailRelationMap from "./note_detail_relation_map.js";
import noteDetailProtectedSession from "./note_detail_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 Sidebar from "./sidebar.js";
@ -37,7 +37,7 @@ const componentClasses = {
let showSidebarInNewTab = true;
optionsInitService.addLoadListener(options => {
optionsService.addLoadListener(options => {
showSidebarInNewTab = options.is('showSidebarInNewTab');
});

File diff suppressed because one or more lines are too long

View File

@ -13,7 +13,7 @@ import treeKeyBindings from "./tree_keybindings.js";
import Branch from '../entities/branch.js';
import NoteShort from '../entities/note_short.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 bundle from "./bundle.js";
@ -331,7 +331,7 @@ async function treeInitialized() {
return;
}
const options = await optionsInit.waitForOptions();
const options = await optionsService.waitForOptions();
const openTabs = options.getJson('openTabs') || [];

View File

@ -1,6 +1,6 @@
import server from "./server.js";
import utils from "./utils.js";
import optionsInitService from "./options_init.js";
import optionsService from "./options.js";
const MIN_ZOOM = 0.5;
const MAX_ZOOM = 2.0;
@ -40,7 +40,7 @@ function getCurrentZoom() {
}
if (utils.isElectron()) {
optionsInitService.addLoadListener(options => setZoomFactor(options.getFloat('zoomFactor')))
optionsService.addLoadListener(options => setZoomFactor(options.getFloat('zoomFactor')))
}
export default {

View File

@ -1,4 +1,4 @@
import optionsInit from "../services/options_init.js";
import optionsService from "../services/options.js";
const WIDGET_TPL = `
<div class="card widget">
@ -84,7 +84,7 @@ class StandardWidget {
async doRenderBody() {}
async isEnabled() {
const option = await optionsInit.getJsonOption(this.widgetName + 'Widget');
const option = await optionsService.getJsonOption(this.widgetName + 'Widget');
return option ? option.enabled : true;
}