mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
broadcast messages to all clients, send also number of outstanding syncs
This commit is contained in:
parent
992238f0b3
commit
cb31e0acf2
@ -165,5 +165,8 @@ ws.onmessage = function (event) {
|
|||||||
|
|
||||||
noteEditor.reload();
|
noteEditor.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const changesToPushCountEl = $("#changesToPushCount");
|
||||||
|
changesToPushCountEl.html(message.changesToPushCount);
|
||||||
}
|
}
|
||||||
};
|
};
|
@ -38,10 +38,10 @@ const status = (function() {
|
|||||||
// noteEditor.reload();
|
// noteEditor.reload();
|
||||||
// }
|
// }
|
||||||
|
|
||||||
changesToPushCountEl.html(resp.changesToPushCount);
|
//changesToPushCountEl.html(resp.changesToPushCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
setInterval(checkStatus, 5 * 1000);
|
//setInterval(checkStatus, 5 * 1000);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
checkStatus
|
checkStatus
|
||||||
|
@ -2,6 +2,7 @@ const sql = require('./sql');
|
|||||||
const source_id = require('./source_id');
|
const source_id = require('./source_id');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
const messaging = require('./messaging');
|
const messaging = require('./messaging');
|
||||||
|
const options = require('./options');
|
||||||
|
|
||||||
async function addNoteSync(noteId, sourceId) {
|
async function addNoteSync(noteId, sourceId) {
|
||||||
await addEntitySync("notes", noteId, sourceId)
|
await addEntitySync("notes", noteId, sourceId)
|
||||||
@ -40,7 +41,7 @@ let startTime = utils.nowTimestamp();
|
|||||||
let sentSyncId = [];
|
let sentSyncId = [];
|
||||||
|
|
||||||
setInterval(async () => {
|
setInterval(async () => {
|
||||||
const syncs = await sql.getResults("SELECT * FROM sync WHERE sync_date >= ?", [startTime]);
|
const syncs = await sql.getResults("SELECT * FROM sync WHERE sync_date >= ? AND source_id != ?", [startTime, source_id.currentSourceId]);
|
||||||
startTime = utils.nowTimestamp();
|
startTime = utils.nowTimestamp();
|
||||||
|
|
||||||
const data = {};
|
const data = {};
|
||||||
@ -59,15 +60,16 @@ setInterval(async () => {
|
|||||||
syncIds.push(sync.id);
|
syncIds.push(sync.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (syncIds.length > 0) {
|
const lastSyncedPush = await sql.getSingleValue("SELECT opt_value FROM options WHERE opt_name = 'last_synced_push'");
|
||||||
messaging.send({
|
|
||||||
type: 'sync',
|
|
||||||
data: data
|
|
||||||
});
|
|
||||||
|
|
||||||
for (const syncId of syncIds) {
|
messaging.send({
|
||||||
sentSyncId.push(syncId);
|
type: 'sync',
|
||||||
}
|
data: data,
|
||||||
|
changesToPushCount: await sql.getSingleValue("SELECT COUNT(*) FROM sync WHERE id > ?", [lastSyncedPush])
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const syncId of syncIds) {
|
||||||
|
sentSyncId.push(syncId);
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user