mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fix not sending latest syncs to client
This commit is contained in:
parent
2f2a14d4b8
commit
68faa47c6f
@ -106,7 +106,7 @@ function checkSyncIdListeners() {
|
|||||||
.filter(l => l.desiredSyncId > lastSyncId);
|
.filter(l => l.desiredSyncId > lastSyncId);
|
||||||
|
|
||||||
syncIdReachedListeners.filter(l => Date.now() > l.start - 60000)
|
syncIdReachedListeners.filter(l => Date.now() > l.start - 60000)
|
||||||
.forEach(l => console.log(`Waiting for syncId ${l.desiredSyncId} while current is ${lastSyncId} for ${Date.now() - l.start}`));
|
.forEach(l => console.log(`Waiting for syncId ${l.desiredSyncId} while current is ${lastSyncId} for ${Math.floor((Date.now() - l.start) / 1000)}s`));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function consumeSyncData() {
|
async function consumeSyncData() {
|
||||||
|
@ -5,7 +5,6 @@ const sql = require('./sql');
|
|||||||
const syncMutexService = require('./sync_mutex');
|
const syncMutexService = require('./sync_mutex');
|
||||||
|
|
||||||
let webSocketServer;
|
let webSocketServer;
|
||||||
let lastSyncId = 0;
|
|
||||||
|
|
||||||
function init(httpServer, sessionParser) {
|
function init(httpServer, sessionParser) {
|
||||||
webSocketServer = new WebSocket.Server({
|
webSocketServer = new WebSocket.Server({
|
||||||
@ -29,13 +28,11 @@ function init(httpServer, sessionParser) {
|
|||||||
ws.on('message', messageJson => {
|
ws.on('message', messageJson => {
|
||||||
const message = JSON.parse(messageJson);
|
const message = JSON.parse(messageJson);
|
||||||
|
|
||||||
lastSyncId = Math.max(lastSyncId, message.lastSyncId);
|
|
||||||
|
|
||||||
if (message.type === 'log-error') {
|
if (message.type === 'log-error') {
|
||||||
log.error('JS Error: ' + message.error);
|
log.error('JS Error: ' + message.error);
|
||||||
}
|
}
|
||||||
else if (message.type === 'ping') {
|
else if (message.type === 'ping') {
|
||||||
syncMutexService.doExclusively(async () => await sendPing(ws, lastSyncId));
|
syncMutexService.doExclusively(async () => await sendPing(ws, message.lastSyncId));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
log.error('Unrecognized message: ');
|
log.error('Unrecognized message: ');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user