mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 11:26:15 +01:00
sync are sent upon DB commit
This commit is contained in:
@@ -4,8 +4,6 @@ const dateUtils = require('./date_utils');
|
||||
const log = require('./log');
|
||||
const cls = require('./cls');
|
||||
|
||||
let syncs = [];
|
||||
|
||||
async function insertEntitySync(entityName, entityId, sourceId) {
|
||||
const sync = {
|
||||
entityName: entityName,
|
||||
@@ -22,9 +20,7 @@ async function insertEntitySync(entityName, entityId, sourceId) {
|
||||
async function addEntitySync(entityName, entityId, sourceId) {
|
||||
const sync = await insertEntitySync(entityName, entityId, sourceId);
|
||||
|
||||
syncs.push(sync);
|
||||
|
||||
setTimeout(() => require('./ws').sendPingToAllClients(), 50);
|
||||
cls.addSyncRow(sync);
|
||||
}
|
||||
|
||||
async function addEntitySyncsForSector(entityName, entityPrimaryKey, sector) {
|
||||
@@ -35,14 +31,6 @@ async function addEntitySyncsForSector(entityName, entityPrimaryKey, sector) {
|
||||
}
|
||||
}
|
||||
|
||||
function getMaxSyncId() {
|
||||
return syncs.length === 0 ? 0 : syncs[syncs.length - 1].id;
|
||||
}
|
||||
|
||||
function getEntitySyncsNewerThan(syncId) {
|
||||
return syncs.filter(s => s.id > syncId);
|
||||
}
|
||||
|
||||
async function cleanupSyncRowsForMissingEntities(entityName, entityPrimaryKey) {
|
||||
await sql.execute(`
|
||||
DELETE
|
||||
@@ -114,7 +102,5 @@ module.exports = {
|
||||
addApiTokenSync: async (apiTokenId, sourceId) => await addEntitySync("api_tokens", apiTokenId, sourceId),
|
||||
addEntitySync,
|
||||
fillAllSyncRows,
|
||||
getEntitySyncsNewerThan,
|
||||
getMaxSyncId,
|
||||
addEntitySyncsForSector
|
||||
};
|
||||
Reference in New Issue
Block a user