diff --git a/lib/types/alert-types.js b/lib/types/alert-types.js --- a/lib/types/alert-types.js +++ b/lib/types/alert-types.js @@ -3,6 +3,7 @@ const alertTypes = Object.freeze({ NOTIF_PERMISSION: 'notif-permission', CONNECT_FARCASTER: 'connect-farcaster', + SIWE_BACKUP_MESSAGE: 'siwe-backup-message', }); type AlertType = $Values; @@ -33,6 +34,7 @@ const defaultAlertInfos: AlertInfos = Object.freeze({ [alertTypes.NOTIF_PERMISSION]: defaultAlertInfo, [alertTypes.CONNECT_FARCASTER]: defaultAlertInfo, + [alertTypes.SIWE_BACKUP_MESSAGE]: defaultAlertInfo, }); export { alertTypes, defaultAlertInfo, defaultAlertInfos }; diff --git a/lib/utils/push-alerts.js b/lib/utils/push-alerts.js --- a/lib/utils/push-alerts.js +++ b/lib/utils/push-alerts.js @@ -27,4 +27,12 @@ ); } -export { shouldSkipPushPermissionAlert, shouldSkipConnectFarcasterAlert }; +function shouldSkipCreateSIWEBackupMessageAlert(alertInfo: AlertInfo): boolean { + return alertInfo.lastAlertTime > Date.now() - msInDay; +} + +export { + shouldSkipPushPermissionAlert, + shouldSkipConnectFarcasterAlert, + shouldSkipCreateSIWEBackupMessageAlert, +}; diff --git a/native/account/registration/missing-registration-data/missing-registration-data-handler.react.js b/native/account/registration/missing-registration-data/missing-registration-data-handler.react.js --- a/native/account/registration/missing-registration-data/missing-registration-data-handler.react.js +++ b/native/account/registration/missing-registration-data/missing-registration-data-handler.react.js @@ -4,8 +4,15 @@ import invariant from 'invariant'; import * as React from 'react'; +import { recordAlertActionType } from 'lib/actions/alert-actions.js'; import { isLoggedIn } from 'lib/selectors/user-selectors.js'; import { accountHasPassword } from 'lib/shared/account-utils.js'; +import { + alertTypes, + type RecordAlertActionPayload, +} from 'lib/types/alert-types.js'; +import { shouldSkipCreateSIWEBackupMessageAlert } from 'lib/utils/push-alerts.js'; +import { useDispatch } from 'lib/utils/redux-utils.js'; import { commCoreModule } from '../../../native-modules.js'; import { CreateMissingSIWEBackupMessageRouteName } from '../../../navigation/route-names.js'; @@ -22,12 +29,18 @@ invariant(registrationContext, 'registrationContext should be set'); const { cachedSelections } = registrationContext; + const createSIWEBAckupMessageAlertInfo = useSelector( + state => state.alertStore.alertInfos[alertTypes.SIWE_BACKUP_MESSAGE], + ); + const dispatch = useDispatch(); + React.useEffect(() => { if ( !enableSIWEBackupCreation || !loggedIn || accountHasPassword(currentUserInfo) || - cachedSelections.siweBackupSecrets + cachedSelections.siweBackupSecrets || + shouldSkipCreateSIWEBackupMessageAlert(createSIWEBAckupMessageAlertInfo) ) { return; } @@ -43,12 +56,24 @@ navigation.navigate<'CreateMissingSIWEBackupMessage'>({ name: CreateMissingSIWEBackupMessageRouteName, }); + + const payload: RecordAlertActionPayload = { + alertType: alertTypes.SIWE_BACKUP_MESSAGE, + time: Date.now(), + }; + + dispatch({ + type: recordAlertActionType, + payload, + }); })(); }, [ currentUserInfo, loggedIn, cachedSelections.siweBackupSecrets, navigation, + createSIWEBAckupMessageAlertInfo, + dispatch, ]); return null; diff --git a/native/account/registration/missing-registration-data/missing-siwe-backup-message.react.js b/native/account/registration/missing-registration-data/missing-siwe-backup-message.react.js --- a/native/account/registration/missing-registration-data/missing-siwe-backup-message.react.js +++ b/native/account/registration/missing-registration-data/missing-siwe-backup-message.react.js @@ -18,30 +18,24 @@ function CreateMissingSIWEBackupMessage(props: Props): React.Node { const styles = useStyles(unboundStyles); - const [siweBackupSecretsPersisted, setSIWEBackupSecretsPersisted] = - React.useState(false); + const { goBack } = props.navigation; const onSuccessfulWalletSignature = React.useCallback( (result: SIWEResult) => { void (async () => { const { message, signature } = result; await commCoreModule.setSIWEBackupSecrets({ message, signature }); - setSIWEBackupSecretsPersisted(true); + goBack(); })(); }, - [setSIWEBackupSecretsPersisted], + [goBack], ); - React.useEffect(() => { - if (siweBackupSecretsPersisted) { - props.navigation.goBack(); - } - }, [siweBackupSecretsPersisted, props]); - return ( ); diff --git a/native/account/registration/siwe-backup-message-creation.react.js b/native/account/registration/siwe-backup-message-creation.react.js --- a/native/account/registration/siwe-backup-message-creation.react.js +++ b/native/account/registration/siwe-backup-message-creation.react.js @@ -30,6 +30,7 @@ type CreateSIWEBackupMessageBaseProps = { +onSuccessfulWalletSignature: (result: SIWEResult) => void, +onExistingWalletSignature?: () => void, + +onSkip?: () => void, }; const CreateSIWEBackupMessageBase: React.ComponentType = @@ -37,7 +38,8 @@ function CreateSIWEBackupMessageBase( props: CreateSIWEBackupMessageBaseProps, ): React.Node { - const { onSuccessfulWalletSignature, onExistingWalletSignature } = props; + const { onSuccessfulWalletSignature, onExistingWalletSignature, onSkip } = + props; const styles = useStyles(unboundStyles); const [panelState, setPanelState] = React.useState('closed'); @@ -94,6 +96,13 @@ ); } + let onSkipButton; + if (onSkip) { + onSkipButton = ( + + ); + } + const body = ( Comm encrypts user backups so that our backend is not able to see user @@ -120,6 +129,7 @@ label={newSignatureButtonText} variant={newSignatureButtonVariant} /> + {onSkipButton} {siwePanel} diff --git a/native/redux/persist.js b/native/redux/persist.js --- a/native/redux/persist.js +++ b/native/redux/persist.js @@ -65,7 +65,11 @@ DEPRECATED_unshimMessageStore, unshimFunc, } from 'lib/shared/unshim-utils.js'; -import { defaultAlertInfo, defaultAlertInfos } from 'lib/types/alert-types.js'; +import { + defaultAlertInfo, + defaultAlertInfos, + alertTypes, +} from 'lib/types/alert-types.js'; import { defaultEnabledApps } from 'lib/types/enabled-apps.js'; import { defaultCalendarQuery } from 'lib/types/entry-types.js'; import { defaultCalendarFilters } from 'lib/types/filter-types.js'; @@ -1288,6 +1292,18 @@ patchRawThreadInfosWithSpecialRole, handleReduxMigrationFailure, ), + [73]: (state: AppState) => { + return { + ...state, + alertStore: { + ...state.alertStore, + alertInfos: { + ...state.alertStore.alertInfos, + [alertTypes.SIWE_BACKUP_MESSAGE]: defaultAlertInfo, + }, + }, + }; + }, }; type PersistedReportStore = $Diff< @@ -1309,7 +1325,7 @@ storage: AsyncStorage, blacklist: persistBlacklist, debug: __DEV__, - version: 72, + version: 73, transforms: [ messageStoreMessagesBlocklistTransform, reportStoreTransform,