From c1fb0fbd3ffbd5f50694c30fcc86a45839ee7b2e Mon Sep 17 00:00:00 2001 From: Jethary Date: Wed, 18 Dec 2024 15:01:09 -0500 Subject: [PATCH 1/2] fix(protocol-designer): refine logic for persisted state --- protocol-designer/src/analytics/reducers.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/protocol-designer/src/analytics/reducers.ts b/protocol-designer/src/analytics/reducers.ts index c894c6be3ce..084e88a6485 100644 --- a/protocol-designer/src/analytics/reducers.ts +++ b/protocol-designer/src/analytics/reducers.ts @@ -23,7 +23,11 @@ const hasOptedIn: Reducer = handleActions( action: RehydratePersistedAction ) => { const persistedState = action.payload?.['analytics.hasOptedIn'] - return persistedState !== undefined ? persistedState : optInInitialState + if (persistedState == null || persistedState?.hasOptedIn == null) { + return optInInitialState + } else { + return persistedState + } }, }, optInInitialState From 4d192fc46261b46b00021daa472dd842d7d2d4da Mon Sep 17 00:00:00 2001 From: Jethary Date: Wed, 18 Dec 2024 15:13:22 -0500 Subject: [PATCH 2/2] add state type --- protocol-designer/src/analytics/reducers.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol-designer/src/analytics/reducers.ts b/protocol-designer/src/analytics/reducers.ts index 084e88a6485..6aff3b00a84 100644 --- a/protocol-designer/src/analytics/reducers.ts +++ b/protocol-designer/src/analytics/reducers.ts @@ -8,7 +8,7 @@ export interface OptInState { hasOptedIn: boolean appVersion?: string } -const optInInitialState = { +const optInInitialState: OptInState = { hasOptedIn: true, }