mirror of
https://github.com/zadam/trilium.git
synced 2025-11-09 14:55:50 +01:00
fix backend to frontend sync with waitForSyncId()
This commit is contained in:
@@ -44,7 +44,7 @@ async function handleMessage(event) {
|
||||
}
|
||||
|
||||
if (message.type === 'sync') {
|
||||
const syncRows = message.data;
|
||||
let syncRows = message.data;
|
||||
lastPingTs = Date.now();
|
||||
|
||||
$outstandingSyncsCount.html(message.outstandingSyncs);
|
||||
@@ -90,6 +90,8 @@ function waitForSyncId(desiredSyncId) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
console.log("Waiting for", desiredSyncId, 'current is', lastProcessedSyncId);
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
syncIdReachedListeners.push({
|
||||
desiredSyncId,
|
||||
@@ -322,13 +324,19 @@ async function processSyncRows(syncRows) {
|
||||
});
|
||||
|
||||
syncRows.filter(sync => sync.entityName === 'options').forEach(sync => {
|
||||
if (sync.entity.name === 'openTabs') {
|
||||
return; // only noise
|
||||
}
|
||||
|
||||
options.set(sync.entity.name, sync.entity.value);
|
||||
|
||||
loadResults.addOption(sync.entity.name);
|
||||
});
|
||||
|
||||
const appContext = (await import("./app_context.js")).default;
|
||||
appContext.triggerEvent('entitiesReloaded', {loadResults});
|
||||
if (!loadResults.isEmpty()) {
|
||||
const appContext = (await import("./app_context.js")).default;
|
||||
appContext.triggerEvent('entitiesReloaded', {loadResults});
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
|
||||
Reference in New Issue
Block a user