diff --git a/lib/utils/farcaster-utils.js b/lib/utils/farcaster-utils.js index 973d01d77..f9e3718a0 100644 --- a/lib/utils/farcaster-utils.js +++ b/lib/utils/farcaster-utils.js @@ -1,69 +1,76 @@ // @flow import invariant from 'invariant'; import * as React from 'react'; import { setSyncedMetadataEntryActionType, clearSyncedMetadataEntryActionType, } from '../actions/synced-metadata-actions.js'; import { IdentityClientContext } from '../shared/identity-client-context.js'; import { syncedMetadataNames } from '../types/synced-metadata-types.js'; import { useSelector, useDispatch } from '../utils/redux-utils.js'; +const DISABLE_CONNECT_FARCASTER_ALERT = true; + function useCurrentUserFID(): ?string { return useSelector( state => state.syncedMetadataStore.syncedMetadata[ syncedMetadataNames.CURRENT_USER_FID ] ?? null, ); } function useLinkFID(): (fid: string) => Promise { const identityClientContext = React.useContext(IdentityClientContext); invariant(identityClientContext, 'identityClientContext should be set'); const { identityClient } = identityClientContext; const { linkFarcasterAccount } = identityClient; const dispatch = useDispatch(); return React.useCallback( async (fid: string) => { await linkFarcasterAccount(fid); dispatch({ type: setSyncedMetadataEntryActionType, payload: { name: syncedMetadataNames.CURRENT_USER_FID, data: fid, }, }); }, [dispatch, linkFarcasterAccount], ); } function useUnlinkFID(): () => Promise { const identityClientContext = React.useContext(IdentityClientContext); invariant(identityClientContext, 'identityClientContext should be set'); const { identityClient } = identityClientContext; const { unlinkFarcasterAccount } = identityClient; const dispatch = useDispatch(); return React.useCallback(async () => { await unlinkFarcasterAccount(); dispatch({ type: clearSyncedMetadataEntryActionType, payload: { name: syncedMetadataNames.CURRENT_USER_FID, }, }); }, [dispatch, unlinkFarcasterAccount]); } -export { useCurrentUserFID, useLinkFID, useUnlinkFID }; +export { + DISABLE_CONNECT_FARCASTER_ALERT, + useCurrentUserFID, + useLinkFID, + useUnlinkFID, +}; diff --git a/lib/utils/push-alerts.js b/lib/utils/push-alerts.js index 47d4f7f63..7abc28e82 100644 --- a/lib/utils/push-alerts.js +++ b/lib/utils/push-alerts.js @@ -1,38 +1,38 @@ // @flow import type { AlertInfo } from '../types/alert-types.js'; import { isDev } from '../utils/dev-utils.js'; -import { usingCommServicesAccessToken } from '../utils/services-utils.js'; +import { DISABLE_CONNECT_FARCASTER_ALERT } from '../utils/farcaster-utils.js'; const msInDay = 24 * 60 * 60 * 1000; function shouldSkipPushPermissionAlert(alertInfo: AlertInfo): boolean { return ( (alertInfo.totalAlerts > 3 && alertInfo.lastAlertTime > Date.now() - msInDay) || (alertInfo.totalAlerts > 6 && alertInfo.lastAlertTime > Date.now() - msInDay * 3) || (alertInfo.totalAlerts > 9 && alertInfo.lastAlertTime > Date.now() - msInDay * 7) ); } function shouldSkipConnectFarcasterAlert(alertInfo: AlertInfo): boolean { // The isDev check is here so that devs don't get continually spammed // with this alert. return ( isDev || - !usingCommServicesAccessToken || + DISABLE_CONNECT_FARCASTER_ALERT || alertInfo.lastAlertTime > Date.now() - msInDay ); } function shouldSkipCreateSIWEBackupMessageAlert(alertInfo: AlertInfo): boolean { return alertInfo.lastAlertTime > Date.now() - msInDay; } export { shouldSkipPushPermissionAlert, shouldSkipConnectFarcasterAlert, shouldSkipCreateSIWEBackupMessageAlert, };