From 1e770ae0af21274dac977b877fc371f76a9e8790 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sun, 3 Apr 2022 02:10:15 +0200 Subject: fix(main): Inconsistent RendererBridge snapshot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Make sure that the snapshot we send to the renderer process corresponds to the state of the SharedStore after the last completed action. Signed-off-by: Kristóf Marussy --- packages/main/src/infrastructure/electron/RendererBridge.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'packages/main/src/infrastructure/electron/RendererBridge.ts') diff --git a/packages/main/src/infrastructure/electron/RendererBridge.ts b/packages/main/src/infrastructure/electron/RendererBridge.ts index 8633b9d..c26aa94 100644 --- a/packages/main/src/infrastructure/electron/RendererBridge.ts +++ b/packages/main/src/infrastructure/electron/RendererBridge.ts @@ -53,7 +53,11 @@ export default class RendererBridge { this.disposeOnPatch = onPatch(store.shared, (patch) => { if (patches === undefined) { // Update unprotected stores (outside an action) right away. - listener([patch]); + try { + listener([patch]); + } finally { + this.snapshot = getSnapshot(store.shared); + } } else { patches.push(patch); } @@ -77,8 +81,6 @@ export default class RendererBridge { abort(undefined); return; } - // Make shure that the saved snapshot is consistent with the patches we're going to send. - this.snapshot = getSnapshot(store.shared); topLevelCall = call; patches = []; try { @@ -91,6 +93,7 @@ export default class RendererBridge { } finally { topLevelCall = undefined; patches = undefined; + this.snapshot = getSnapshot(store.shared); } } }); -- cgit v1.2.3-70-g09d2