mirror of
https://github.com/zadam/trilium.git
synced 2025-11-04 20:36:13 +01:00
fix propagating note reloads
This commit is contained in:
@@ -29,24 +29,6 @@ function focusAndSelectTitle() {
|
||||
appContext.trigger('focusAndSelectTitle');
|
||||
}
|
||||
|
||||
ws.subscribeToOutsideSyncMessages(syncData => {
|
||||
const noteIdsToRefresh = new Set();
|
||||
|
||||
syncData
|
||||
.filter(sync => sync.entityName === 'notes')
|
||||
.forEach(sync => noteIdsToRefresh.add(sync.entityId));
|
||||
|
||||
// we need to reload because of promoted attributes
|
||||
syncData
|
||||
.filter(sync => sync.entityName === 'attributes')
|
||||
.forEach(sync => noteIdsToRefresh.add(sync.noteId));
|
||||
|
||||
// FIXME
|
||||
for (const noteId of noteIdsToRefresh) {
|
||||
appContext.refreshTabs(null, noteId);
|
||||
}
|
||||
});
|
||||
|
||||
function noteChanged() {
|
||||
const activeTabContext = appContext.getActiveTabContext();
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import server from "./server.js";
|
||||
|
||||
const $outstandingSyncsCount = $("#outstanding-syncs-count");
|
||||
|
||||
const outsideSyncMessageHandlers = [];
|
||||
const messageHandlers = [];
|
||||
|
||||
let ws;
|
||||
@@ -29,10 +28,6 @@ function subscribeToMessages(messageHandler) {
|
||||
messageHandlers.push(messageHandler);
|
||||
}
|
||||
|
||||
function subscribeToOutsideSyncMessages(messageHandler) {
|
||||
outsideSyncMessageHandlers.push(messageHandler);
|
||||
}
|
||||
|
||||
// used to serialize sync operations
|
||||
let consumeQueuePromise = null;
|
||||
|
||||
@@ -129,18 +124,10 @@ async function consumeSyncData() {
|
||||
const allSyncData = syncDataQueue;
|
||||
syncDataQueue = [];
|
||||
|
||||
const outsideSyncData = allSyncData.filter(sync => sync.sourceId !== glob.sourceId);
|
||||
|
||||
try {
|
||||
const appContext = (await import("./app_context.js")).default;
|
||||
const treeCache = (await import("./tree_cache.js")).default;
|
||||
|
||||
// the update process should be synchronous as a whole but individual handlers can run in parallel
|
||||
await Promise.all([
|
||||
() => appContext.trigger('syncData', {data: allSyncData}),
|
||||
() => treeCache.processSyncRows(allSyncData),
|
||||
...outsideSyncMessageHandlers.map(syncHandler => runSafely(syncHandler, outsideSyncData))
|
||||
]);
|
||||
await treeCache.processSyncRows(allSyncData);
|
||||
}
|
||||
catch (e) {
|
||||
logError(`Encountered error ${e.message}, reloading frontend.`);
|
||||
@@ -213,7 +200,6 @@ subscribeToMessages(message => {
|
||||
export default {
|
||||
logError,
|
||||
subscribeToMessages,
|
||||
subscribeToOutsideSyncMessages,
|
||||
waitForSyncId,
|
||||
waitForMaxKnownSyncId
|
||||
};
|
||||
Reference in New Issue
Block a user