mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
server-ts: Port services/options
This commit is contained in:
parent
532ed1d3f9
commit
a154dc76ce
@ -13,7 +13,7 @@ class BOption extends AbstractBeccaEntity<BOption> {
|
||||
static get hashedProperties() { return ["name", "value"]; }
|
||||
|
||||
name!: string;
|
||||
value!: string | number;
|
||||
value!: string;
|
||||
isSynced!: boolean;
|
||||
|
||||
constructor(row?: OptionRow) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const sqlInit = require('../../services/sql_init');
|
||||
const setupService = require('../../services/setup.js');
|
||||
const setupService = require('../../services/setup');
|
||||
const log = require('../../services/log');
|
||||
const appInfo = require('../../services/app_info');
|
||||
|
||||
@ -24,7 +24,7 @@ function setupSyncFromServer(req) {
|
||||
}
|
||||
|
||||
function saveSyncSeed(req) {
|
||||
const {options, syncVersion} = req.body;
|
||||
const { options, syncVersion } = req.body;
|
||||
|
||||
if (appInfo.syncVersion !== syncVersion) {
|
||||
const message = `Could not setup sync since local sync protocol version is ${appInfo.syncVersion} while remote is ${syncVersion}. To fix this issue, use same Trilium version on all instances.`;
|
||||
|
@ -1,7 +1,7 @@
|
||||
"use strict";
|
||||
|
||||
const sqlInit = require('../services/sql_init');
|
||||
const setupService = require('../services/setup.js');
|
||||
const setupService = require('../services/setup');
|
||||
const utils = require('../services/utils');
|
||||
const assetPath = require('../services/asset_path');
|
||||
const appPath = require('../services/app_path');
|
||||
@ -10,7 +10,7 @@ function setupPage(req, res) {
|
||||
if (sqlInit.isDbInitialized()) {
|
||||
if (utils.isElectron()) {
|
||||
const windowService = require('../services/window');
|
||||
const {app} = require('electron');
|
||||
const { app } = require('electron');
|
||||
windowService.createMainWindow(app);
|
||||
windowService.closeSetupWindow();
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ function getOptionOrNull(name: string): string | null {
|
||||
return option ? option.value : null;
|
||||
}
|
||||
|
||||
function getOption(name: string): string {
|
||||
function getOption(name: string) {
|
||||
const val = getOptionOrNull(name);
|
||||
|
||||
if (val === null) {
|
||||
@ -44,7 +44,7 @@ function getOptionInt(name: string, defaultValue?: number): number {
|
||||
function getOptionBool(name: string): boolean {
|
||||
const val = getOption(name);
|
||||
|
||||
if (!['true', 'false'].includes(val)) {
|
||||
if (typeof val !== "string" || !['true', 'false'].includes(val)) {
|
||||
throw new Error(`Could not parse '${val}' into boolean for option '${name}'`);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ function getOptionBool(name: string): boolean {
|
||||
}
|
||||
|
||||
function setOption(name: string, value: string | number | boolean) {
|
||||
if (value === true || value === false) {
|
||||
if (value === true || value === false || typeof value === "number") {
|
||||
value = value.toString();
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ function setOption(name: string, value: string | number | boolean) {
|
||||
}
|
||||
}
|
||||
|
||||
function createOption(name: string, value: string, isSynced: boolean) {
|
||||
function createOption(name: string, value: string | number, isSynced: boolean) {
|
||||
// to avoid circular dependency, need to find a better solution
|
||||
const BOption = require('../becca/entities/boption');
|
||||
|
||||
@ -84,7 +84,7 @@ function getOptions() {
|
||||
}
|
||||
|
||||
function getOptionMap() {
|
||||
const map: Record<string, string> = {};
|
||||
const map: Record<string | number, string> = {};
|
||||
|
||||
for (const option of Object.values(becca.options)) {
|
||||
map[option.name] = option.value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user