-
Notifications
You must be signed in to change notification settings - Fork 188
SEL-483: Implement recovery backup prompts #710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
4b4b5cd
c6f63ff
bfb3d5d
4457f79
329294a
e2dd66a
7ca15aa
70f3b25
7a8d8e2
8e823d4
8a3cdac
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import { useEffect } from 'react'; | ||
|
Check warning on line 1 in app/src/hooks/useRecoveryPrompts.ts
|
||
| import { navigationRef } from '../navigation'; | ||
| import { useModal } from './useModal'; | ||
| import { useSettingStore } from '../stores/settingStore'; | ||
|
|
||
| const modalParams = { | ||
| titleText: 'Protect your account', | ||
| bodyText: | ||
| 'Enable cloud backup or save your recovery phrase so you can recover your account.', | ||
| buttonText: 'Back up now', | ||
| onButtonPress: async () => { | ||
| if (navigationRef.isReady()) { | ||
| navigationRef.navigate('CloudBackupSettings', { | ||
| nextScreen: 'SaveRecoveryPhrase', | ||
| }); | ||
| } | ||
| }, | ||
| onModalDismiss: () => {}, | ||
| } as const; | ||
|
|
||
| export default function useRecoveryPrompts() { | ||
| const { loginCount, cloudBackupEnabled, hasViewedRecoveryPhrase } = | ||
| useSettingStore(); | ||
| const { showModal, visible } = useModal(modalParams); | ||
|
|
||
| useEffect(() => { | ||
| if (!navigationRef.isReady()) { | ||
| return; | ||
| } | ||
| if (!cloudBackupEnabled && !hasViewedRecoveryPhrase) { | ||
| const shouldPrompt = | ||
| loginCount > 0 && (loginCount <= 3 || (loginCount - 3) % 5 === 0); | ||
| if (shouldPrompt && !visible) { | ||
| showModal(); | ||
| } | ||
| } | ||
| }, [loginCount, cloudBackupEnabled, hasViewedRecoveryPhrase, visible, showModal]); | ||
|
Check warning on line 37 in app/src/hooks/useRecoveryPrompts.ts
|
||
|
|
||
| return { visible }; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.