Skip to content

Commit 1d56182

Browse files
authored
fix: face biometrics on android (#1607)
Signed-off-by: Bryce McMath <bryce.j.mcmath@gmail.com>
1 parent 6aca028 commit 1d56182

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

.changeset/warm-words-sleep.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@bifold/core': patch
3+
---
4+
5+
Prevent accidentally overwritten persisted state on load

packages/core/src/contexts/network.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const NetworkProvider = ({ children }: PropsWithChildren) => {
2424
const [isNetInfoModalDisplayed, setIsNetInfoModalDisplayed] = useState<boolean>(false)
2525
const { t } = useTranslation()
2626
const [hasShown, setHasShown] = useState(false)
27-
const [, dispatch] = useStore()
27+
const [store, dispatch] = useStore()
2828

2929
const displayNetInfoModal = useCallback(() => {
3030
setIsNetInfoModalDisplayed(true)
@@ -85,6 +85,12 @@ export const NetworkProvider = ({ children }: PropsWithChildren) => {
8585
}, [dispatch, t])
8686

8787
useEffect(() => {
88+
// This early return prevents the dispatches from overwriting
89+
// the persisted state until the state is loaded from storage
90+
if (!store.stateLoaded) {
91+
return
92+
}
93+
8894
const internetReachable = assertInternetReachable()
8995
if (internetReachable) {
9096
setHasShown(false)
@@ -98,7 +104,7 @@ export const NetworkProvider = ({ children }: PropsWithChildren) => {
98104
if (internetReachable === false && !hasShown) {
99105
showNetworkWarning()
100106
}
101-
}, [showNetworkWarning, assertInternetReachable, hasShown, dispatch])
107+
}, [store.stateLoaded, showNetworkWarning, assertInternetReachable, hasShown, dispatch])
102108

103109
return (
104110
<NetworkContext.Provider

0 commit comments

Comments
 (0)