Skip to content

Build your personal knowledge base with Trilium Notes

electron fixes

azivnere827ddffb927
diff --git a/src/public/javascripts/migration.js b/src/public/javascripts/migration.js
index 30240650cc..c743a4d19a 100644
--- a/src/public/javascripts/migration.js
+++ b/src/public/javascripts/migration.js
@@ -1,20 +1,19 @@
import server from './services/server.js';
-$(document).ready(() => {
- server.get('migration').then(result => {
- const appDbVersion = result.app_dbVersion;
- const dbVersion = result.dbVersion;
+$(document).ready(async () => {
+ const {appDbVersion, dbVersion} = await server.get('migration');
- if (appDbVersion === dbVersion) {
- $("#up-to-date").show();
- }
- else {
- $("#need-to-migrate").show();
+ console.log("HI", {appDbVersion, dbVersion});
- $("#app-db-version").html(appDbVersion);
- $("#db-version").html(dbVersion);
- }
- });
+ if (appDbVersion === dbVersion) {
+ $("#up-to-date").show();
+ }
+ else {
+ $("#need-to-migrate").show();
+
+ $("#app-db-version").html(appDbVersion);
+ $("#db-version").html(dbVersion);
+ }
});
$("#run-migration").click(async () => {
@@ -37,4 +36,11 @@ $("#run-migration").click(async () => {
$("#migration-table").append(row);
}
+});
+
+// copy of this shortcut to be able to debug migration problems
+$(document).bind('keydown', 'ctrl+shift+i', () => {
+ require('electron').remote.getCurrentWindow().toggleDevTools();
+
+ return false;
});
\ No newline at end of file
diff --git a/src/public/javascripts/services/messaging.js b/src/public/javascripts/services/messaging.js
index 64dc42b8ff..e5a381d3ba 100644
--- a/src/public/javascripts/services/messaging.js
+++ b/src/public/javascripts/services/messaging.js
@@ -100,7 +100,7 @@ setTimeout(() => {
lastSyncId: lastSyncId
}));
}, 1000);
-}, 1000);
+}, 0);
export default {
logError,
diff --git a/src/public/javascripts/services/server.js b/src/public/javascripts/services/server.js
index c8aaf955ff..a0619c6b18 100644
--- a/src/public/javascripts/services/server.js
+++ b/src/public/javascripts/services/server.js
@@ -85,19 +85,17 @@ async function ajax(url, method, data) {
});
}
-setTimeout(() => {
- if (utils.isElectron()) {
- const ipc = require('electron').ipcRenderer;
+if (utils.isElectron()) {
+ const ipc = require('electron').ipcRenderer;
- ipc.on('server-response', (event, arg) => {
- console.log(utils.now(), "Response #" + arg.requestId + ": " + arg.statusCode);
+ ipc.on('server-response', (event, arg) => {
+ console.log(utils.now(), "Response #" + arg.requestId + ": " + arg.statusCode);
- reqResolves[arg.requestId](arg.body);
+ reqResolves[arg.requestId](arg.body);
- delete reqResolves[arg.requestId];
- });
- }
-}, 100);
+ delete reqResolves[arg.requestId];
+ });
+}
export default {
get,
diff --git a/src/routes/api/migration.js b/src/routes/api/migration.js
index 74f7ab0128..26121eb548 100644
--- a/src/routes/api/migration.js
+++ b/src/routes/api/migration.js
@@ -7,7 +7,7 @@ const appInfo = require('../../services/app_info');
async function getMigrationInfo() {
return {
dbVersion: parseInt(await optionService.getOption('dbVersion')),
- app_dbVersion: appInfo.dbVersion
+ appDbVersion: appInfo.dbVersion
};
}
diff --git a/src/routes/electron.js b/src/routes/electron.js
index 816ed1baba..1049630055 100644
--- a/src/routes/electron.js
+++ b/src/routes/electron.js
@@ -19,6 +19,7 @@ function init(app) {
res.status = function(statusCode) {
res.statusCode = statusCode;
+ return res;
};
res.send = function(obj) {
diff --git a/src/services/scheduler.js b/src/services/scheduler.js
index c7ea04cab1..e2f729cd9c 100644
--- a/src/services/scheduler.js
+++ b/src/services/scheduler.js
@@ -1,6 +1,7 @@
const scriptService = require('./script');
const repository = require('./repository');
const cls = require('./cls');
+const sqlInit = require('./sql_init');
async function runNotesWithLabel(runAttrValue) {
const notes = await repository.getEntities(`
@@ -19,8 +20,10 @@ async function runNotesWithLabel(runAttrValue) {
}
}
-setTimeout(cls.wrap(() => runNotesWithLabel('backendStartup')), 10 * 1000);
+sqlInit.dbReady.then(() => {
+ 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);
\ No newline at end of file
+ setInterval(cls.wrap(() => runNotesWithLabel('daily')), 24 * 3600 * 1000);
+});
\ No newline at end of file
diff --git a/src/www b/src/www
index 5fad53097b..a8aac14c5a 100755
--- a/src/www
+++ b/src/www
@@ -18,8 +18,6 @@ const log = require('./services/log');
const appInfo = require('./services/app_info');
const messagingService = require('./services/messaging');
const utils = require('./services/utils');
-const sql = require('./services/sql');
-const sqlInit = require('./services/sql_init');
const port = normalizePort(config['Network']['port'] || '3000');
app.set('port', port);
@@ -56,7 +54,7 @@ httpServer.listen(port);
httpServer.on('error', onError);
httpServer.on('listening', onListening);
-sqlInit.dbReady.then(() => messagingService.init(httpServer, sessionParser));
+messagingService.init(httpServer, sessionParser);
if (utils.isElectron()) {
const electronRouting = require('./routes/electron');