mirror of
https://github.com/zadam/trilium.git
synced 2025-11-09 06:45:49 +01:00
added sync mutex to ping messages
This commit is contained in:
@@ -97,6 +97,8 @@ class TreeCache {
|
||||
const missingNoteIds = noteIds.filter(noteId => this.notes[noteId] === undefined);
|
||||
|
||||
if (missingNoteIds.length > 0) {
|
||||
console.trace("Refreshing", missingNoteIds);
|
||||
|
||||
const resp = await server.post('tree/load', { noteIds: missingNoteIds });
|
||||
|
||||
this.addResp(resp.notes, resp.branches, resp.relations);
|
||||
|
||||
@@ -32,17 +32,16 @@ class EditedNotesWidget extends StandardWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
const noteIds = editedNotes.flatMap(note => note.notePath);
|
||||
const noteIds = editedNotes.flatMap(note => note.noteId);
|
||||
|
||||
await treeCache.getNotes(noteIds, true); // preload all at once
|
||||
|
||||
const $list = $('<ul>');
|
||||
|
||||
for (const editedNote of editedNotes) {
|
||||
const note = await treeCache.getNote(editedNote.noteId, true);
|
||||
const $item = $("<li>");
|
||||
|
||||
if (!note) {
|
||||
if (editedNote.isDeleted) {
|
||||
$item.append($("<i>").text(editedNote.title + " (deleted)"));
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -2,8 +2,10 @@ const WebSocket = require('ws');
|
||||
const utils = require('./utils');
|
||||
const log = require('./log');
|
||||
const sql = require('./sql');
|
||||
const syncMutexService = require('./sync_mutex');
|
||||
|
||||
let webSocketServer;
|
||||
let lastSyncId = 0;
|
||||
|
||||
function init(httpServer, sessionParser) {
|
||||
webSocketServer = new WebSocket.Server({
|
||||
@@ -27,11 +29,13 @@ 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') {
|
||||
sendPing(ws, message.lastSyncId);
|
||||
syncMutexService.doExclusively(async () => await sendPing(ws, lastSyncId));
|
||||
}
|
||||
else {
|
||||
log.error('Unrecognized message: ');
|
||||
|
||||
Reference in New Issue
Block a user