Page MenuHomePhabricator

D12683.id42164.diff
No OneTemporary

D12683.id42164.diff

diff --git a/lib/utils/farcaster-utils.js b/lib/utils/farcaster-utils.js
--- a/lib/utils/farcaster-utils.js
+++ b/lib/utils/farcaster-utils.js
@@ -12,14 +12,21 @@
import { useSelector, useDispatch } from '../utils/redux-utils.js';
const DISABLE_CONNECT_FARCASTER_ALERT = true;
+const NO_FID_METADATA = 'NONE';
function useCurrentUserFID(): ?string {
- return useSelector(
+ const currentUserFID = useSelector(
state =>
state.syncedMetadataStore.syncedMetadata[
syncedMetadataNames.CURRENT_USER_FID
- ] ?? null,
+ ] ?? undefined,
);
+
+ if (currentUserFID === NO_FID_METADATA) {
+ return null;
+ }
+
+ return currentUserFID;
}
function useLinkFID(): (fid: string) => Promise<void> {
@@ -70,6 +77,7 @@
export {
DISABLE_CONNECT_FARCASTER_ALERT,
+ NO_FID_METADATA,
useCurrentUserFID,
useLinkFID,
useUnlinkFID,
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
@@ -17,13 +17,18 @@
);
}
-function shouldSkipConnectFarcasterAlert(alertInfo: AlertInfo): boolean {
+function shouldSkipConnectFarcasterAlert(
+ alertInfo: AlertInfo,
+ fid: ?string,
+): boolean {
// The isDev check is here so that devs don't get continually spammed
// with this alert.
return (
isDev ||
DISABLE_CONNECT_FARCASTER_ALERT ||
- alertInfo.lastAlertTime > Date.now() - msInDay
+ !!fid ||
+ fid === null ||
+ alertInfo.totalAlerts > 0
);
}
diff --git a/native/account/registration/registration-server-call.js b/native/account/registration/registration-server-call.js
--- a/native/account/registration/registration-server-call.js
+++ b/native/account/registration/registration-server-call.js
@@ -23,6 +23,7 @@
} from 'lib/types/account-types.js';
import { syncedMetadataNames } from 'lib/types/synced-metadata-types.js';
import { getMessageForException } from 'lib/utils/errors.js';
+import { NO_FID_METADATA } from 'lib/utils/farcaster-utils.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
@@ -356,15 +357,14 @@
payload: passedKeyserverURL,
});
}
- if (farcasterID) {
- dispatch({
- type: setSyncedMetadataEntryActionType,
- payload: {
- name: syncedMetadataNames.CURRENT_USER_FID,
- data: farcasterID,
- },
- });
- }
+ const fidToSave = farcasterID ?? NO_FID_METADATA;
+ dispatch({
+ type: setSyncedMetadataEntryActionType,
+ payload: {
+ name: syncedMetadataNames.CURRENT_USER_FID,
+ data: fidToSave,
+ },
+ });
if (siweBackupSecrets) {
await commCoreModule.setSIWEBackupSecrets(siweBackupSecrets);
}
diff --git a/native/components/connect-farcaster-alert-handler.react.js b/native/components/connect-farcaster-alert-handler.react.js
--- a/native/components/connect-farcaster-alert-handler.react.js
+++ b/native/components/connect-farcaster-alert-handler.react.js
@@ -40,8 +40,7 @@
if (
!loggedIn ||
!isActive ||
- !!fid ||
- shouldSkipConnectFarcasterAlert(connectFarcasterAlertInfo)
+ shouldSkipConnectFarcasterAlert(connectFarcasterAlertInfo, fid)
) {
return;
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 9:45 AM (17 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2570105
Default Alt Text
D12683.id42164.diff (3 KB)

Event Timeline