diff options
Diffstat (limited to 'packages/preload/src/contextBridge')
-rw-r--r-- | packages/preload/src/contextBridge/__tests__/createSophieRenderer.spec.ts | 16 | ||||
-rw-r--r-- | packages/preload/src/contextBridge/createSophieRenderer.ts | 2 |
2 files changed, 10 insertions, 8 deletions
diff --git a/packages/preload/src/contextBridge/__tests__/createSophieRenderer.spec.ts b/packages/preload/src/contextBridge/__tests__/createSophieRenderer.spec.ts index 2652c4e..4411789 100644 --- a/packages/preload/src/contextBridge/__tests__/createSophieRenderer.spec.ts +++ b/packages/preload/src/contextBridge/__tests__/createSophieRenderer.spec.ts | |||
@@ -51,11 +51,13 @@ const snapshot: SharedStoreSnapshotIn = { | |||
51 | shouldUseDarkColors: true, | 51 | shouldUseDarkColors: true, |
52 | }; | 52 | }; |
53 | 53 | ||
54 | const patch: IJsonPatch = { | 54 | const patch: IJsonPatch[] = [ |
55 | op: 'replace', | 55 | { |
56 | path: 'foo', | 56 | op: 'replace', |
57 | value: 'bar', | 57 | path: 'foo', |
58 | }; | 58 | value: 'bar', |
59 | }, | ||
60 | ]; | ||
59 | 61 | ||
60 | const action: Action = { | 62 | const action: Action = { |
61 | action: 'set-theme-source', | 63 | action: 'set-theme-source', |
@@ -90,7 +92,7 @@ describe('SharedStoreConnector', () => { | |||
90 | // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars | 92 | // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars |
91 | onSnapshot: jest.fn((_snapshot: SharedStoreSnapshotIn) => {}), | 93 | onSnapshot: jest.fn((_snapshot: SharedStoreSnapshotIn) => {}), |
92 | // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars | 94 | // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars |
93 | onPatch: jest.fn((_patch: IJsonPatch) => {}), | 95 | onPatch: jest.fn((_patch: IJsonPatch[]) => {}), |
94 | }; | 96 | }; |
95 | 97 | ||
96 | beforeEach(() => { | 98 | beforeEach(() => { |
@@ -234,7 +236,7 @@ describe('SharedStoreConnector', () => { | |||
234 | // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars | 236 | // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars |
235 | onSnapshot: jest.fn((_snapshot: SharedStoreSnapshotIn) => {}), | 237 | onSnapshot: jest.fn((_snapshot: SharedStoreSnapshotIn) => {}), |
236 | // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars | 238 | // eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars |
237 | onPatch: jest.fn((_patch: IJsonPatch) => {}), | 239 | onPatch: jest.fn((_patch: IJsonPatch[]) => {}), |
238 | }; | 240 | }; |
239 | 241 | ||
240 | it('should fetch a second snapshot', async () => { | 242 | it('should fetch a second snapshot', async () => { |
diff --git a/packages/preload/src/contextBridge/createSophieRenderer.ts b/packages/preload/src/contextBridge/createSophieRenderer.ts index 41accfd..6003c8b 100644 --- a/packages/preload/src/contextBridge/createSophieRenderer.ts +++ b/packages/preload/src/contextBridge/createSophieRenderer.ts | |||
@@ -42,7 +42,7 @@ class SharedStoreConnector { | |||
42 | (_event, patch) => { | 42 | (_event, patch) => { |
43 | try { | 43 | try { |
44 | // `mobx-state-tree` will validate the patch, so we can safely cast here. | 44 | // `mobx-state-tree` will validate the patch, so we can safely cast here. |
45 | this.listener?.onPatch(patch as IJsonPatch); | 45 | this.listener?.onPatch(patch as IJsonPatch[]); |
46 | } catch (error) { | 46 | } catch (error) { |
47 | log.error('Shared store listener onPatch failed', error); | 47 | log.error('Shared store listener onPatch failed', error); |
48 | this.listener = undefined; | 48 | this.listener = undefined; |