aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-04-03 02:10:15 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-05-16 00:54:59 +0200
commit1e770ae0af21274dac977b877fc371f76a9e8790 (patch)
tree4290c0e20968c25b15151359d1484bd7ade1b35c /packages
parentfeat(main): Language setting in config file (diff)
downloadsophie-1e770ae0af21274dac977b877fc371f76a9e8790.tar.gz
sophie-1e770ae0af21274dac977b877fc371f76a9e8790.tar.zst
sophie-1e770ae0af21274dac977b877fc371f76a9e8790.zip
fix(main): Inconsistent RendererBridge snapshot
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 <kristof@marussy.com>
Diffstat (limited to 'packages')
-rw-r--r--packages/main/src/infrastructure/electron/RendererBridge.ts9
1 files changed, 6 insertions, 3 deletions
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 {
53 this.disposeOnPatch = onPatch(store.shared, (patch) => { 53 this.disposeOnPatch = onPatch(store.shared, (patch) => {
54 if (patches === undefined) { 54 if (patches === undefined) {
55 // Update unprotected stores (outside an action) right away. 55 // Update unprotected stores (outside an action) right away.
56 listener([patch]); 56 try {
57 listener([patch]);
58 } finally {
59 this.snapshot = getSnapshot(store.shared);
60 }
57 } else { 61 } else {
58 patches.push(patch); 62 patches.push(patch);
59 } 63 }
@@ -77,8 +81,6 @@ export default class RendererBridge {
77 abort(undefined); 81 abort(undefined);
78 return; 82 return;
79 } 83 }
80 // Make shure that the saved snapshot is consistent with the patches we're going to send.
81 this.snapshot = getSnapshot(store.shared);
82 topLevelCall = call; 84 topLevelCall = call;
83 patches = []; 85 patches = [];
84 try { 86 try {
@@ -91,6 +93,7 @@ export default class RendererBridge {
91 } finally { 93 } finally {
92 topLevelCall = undefined; 94 topLevelCall = undefined;
93 patches = undefined; 95 patches = undefined;
96 this.snapshot = getSnapshot(store.shared);
94 } 97 }
95 } 98 }
96 }); 99 });