Skip to content

Commit

Permalink
fix(protocol-designer): change initial value from null to true
Browse files Browse the repository at this point in the history
change initial value from null to true

close RQA-3797
  • Loading branch information
koji committed Dec 18, 2024
1 parent 4bb6a9c commit f5e79f4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions protocol-designer/src/analytics/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import type { Action } from '../types'
import type { SetOptIn } from './actions'
import type { RehydratePersistedAction } from '../persist'
export interface OptInState {
hasOptedIn: boolean | null
hasOptedIn: boolean
appVersion?: string
}
const optInInitialState = {
hasOptedIn: null,
hasOptedIn: true,
}

// @ts-expect-error(sb, 2021-6-17): cannot use string literals as action type
Expand Down
10 changes: 4 additions & 6 deletions protocol-designer/src/pages/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function Settings(): JSX.Element {
const [showAnnouncementModal, setShowAnnouncementModal] = useState<boolean>(
false
)
const analytics = useSelector(analyticsSelectors.getHasOptedIn)
const { hasOptedIn } = useSelector(analyticsSelectors.getHasOptedIn)
const flags = useSelector(getFeatureFlagData)
const canClearHintDismissals = useSelector(
tutorialSelectors.getCanClearHintDismissals
Expand Down Expand Up @@ -274,23 +274,21 @@ export function Settings(): JSX.Element {
data-testid="analyticsToggle"
size="2rem"
css={
Boolean(analytics.hasOptedIn)
Boolean(hasOptedIn)
? TOGGLE_ENABLED_STYLES
: TOGGLE_DISABLED_STYLES
}
onClick={() =>
dispatch(
analytics.hasOptedIn
hasOptedIn
? analyticsActions.optOut()
: analyticsActions.optIn()
)
}
>
<Icon
name={
analytics.hasOptedIn
? 'ot-toggle-input-on'
: 'ot-toggle-input-off'
hasOptedIn ? 'ot-toggle-input-on' : 'ot-toggle-input-off'
}
height="1rem"
/>
Expand Down
2 changes: 1 addition & 1 deletion protocol-designer/src/persist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface RehydratePersistedAction {
'tutorial.dismissedHints'?: Record<string, any>
'featureFlags.flags'?: Record<string, any>
'analytics.hasOptedIn'?: {
hasOptedIn: boolean | null
hasOptedIn: boolean
appVersion?: string
}
}
Expand Down

0 comments on commit f5e79f4

Please sign in to comment.