mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	fix not sending latest syncs to client
This commit is contained in:
		| @@ -106,7 +106,7 @@ function checkSyncIdListeners() { | ||||
|         .filter(l => l.desiredSyncId > lastSyncId); | ||||
|  | ||||
|     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() { | ||||
|   | ||||
| @@ -5,7 +5,6 @@ const sql = require('./sql'); | ||||
| const syncMutexService = require('./sync_mutex'); | ||||
|  | ||||
| let webSocketServer; | ||||
| let lastSyncId = 0; | ||||
|  | ||||
| function init(httpServer, sessionParser) { | ||||
|     webSocketServer = new WebSocket.Server({ | ||||
| @@ -29,13 +28,11 @@ function init(httpServer, sessionParser) { | ||||
|         ws.on('message', messageJson => { | ||||
|             const message = JSON.parse(messageJson); | ||||
|  | ||||
|             lastSyncId = Math.max(lastSyncId, message.lastSyncId); | ||||
|  | ||||
|             if (message.type === 'log-error') { | ||||
|                 log.error('JS Error: ' + message.error); | ||||
|             } | ||||
|             else if (message.type === 'ping') { | ||||
|                 syncMutexService.doExclusively(async () => await sendPing(ws, lastSyncId)); | ||||
|                 syncMutexService.doExclusively(async () => await sendPing(ws, message.lastSyncId)); | ||||
|             } | ||||
|             else { | ||||
|                 log.error('Unrecognized message: '); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user