Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3345116
D12683.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12683.diff
View Options
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,25 @@
import { useSelector, useDispatch } from '../utils/redux-utils.js';
const DISABLE_CONNECT_FARCASTER_ALERT = true;
+const NO_FID_METADATA = 'NONE';
function useCurrentUserFID(): ?string {
- return useSelector(
+ // There is a distinction between null & undefined for the fid value.
+ // If the fid is null this means that the user has decided NOT to set
+ // a Farcaster association. If the fid is undefined this means that
+ // the user has not yet been prompted to set a Farcaster association.
+ 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 +81,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,17 @@
);
}
-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 !== undefined ||
+ 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
@@ -36,8 +36,7 @@
if (
!loggedIn ||
!isActive ||
- !!fid ||
- shouldSkipConnectFarcasterAlert(connectFarcasterAlertInfo)
+ shouldSkipConnectFarcasterAlert(connectFarcasterAlertInfo, fid)
) {
return;
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 5:32 AM (13 h, 21 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2569105
Default Alt Text
D12683.diff (3 KB)
Attached To
Mode
D12683: [native] update connect farcaster prompt to be less annyoying
Attached
Detach File
Event Timeline
Log In to Comment