Page MenuHomePhabricator

D12696.diff
No OneTemporary

D12696.diff

diff --git a/lib/components/farcaster-data-handler.react.js b/lib/components/farcaster-data-handler.react.js
--- a/lib/components/farcaster-data-handler.react.js
+++ b/lib/components/farcaster-data-handler.react.js
@@ -9,10 +9,9 @@
} from '../actions/relationship-actions.js';
import { NeynarClientContext } from '../components/neynar-client-provider.react.js';
import { useLegacyAshoatKeyserverCall } from '../keyserver-conn/legacy-keyserver-call.js';
-import { cookieSelector } from '../selectors/keyserver-selectors.js';
+import { isLoggedInToAuthoritativeKeyserver } from '../selectors/user-selectors.js';
import { IdentityClientContext } from '../shared/identity-client-context.js';
import { relationshipActions } from '../types/relationship-types.js';
-import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { useCurrentUserFID } from '../utils/farcaster-utils.js';
import { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
import { useSelector, useDispatch } from '../utils/redux-utils.js';
@@ -21,10 +20,11 @@
function FarcasterDataHandler(): React.Node {
const isActive = useSelector(state => state.lifecycleState !== 'background');
- const cookie = useSelector(cookieSelector(authoritativeKeyserverID()));
- const hasUserCookie = !!(cookie && cookie.startsWith('user='));
+ const isLoggedInToAuthKeyserver = useSelector(
+ isLoggedInToAuthoritativeKeyserver,
+ );
const currentUserID = useSelector(state => state.currentUserInfo?.id);
- const loggedIn = !!currentUserID && hasUserCookie;
+ const loggedIn = !!currentUserID && isLoggedInToAuthKeyserver;
const neynarClient = React.useContext(NeynarClientContext)?.client;
diff --git a/lib/handlers/user-infos-handler.react.js b/lib/handlers/user-infos-handler.react.js
--- a/lib/handlers/user-infos-handler.react.js
+++ b/lib/handlers/user-infos-handler.react.js
@@ -14,11 +14,10 @@
import { useLegacyAshoatKeyserverCall } from '../keyserver-conn/legacy-keyserver-call.js';
import {
usersWithMissingDeviceListSelector,
- isLoggedInToKeyserver,
+ isLoggedInToAuthoritativeKeyserver,
} from '../selectors/user-selectors.js';
import { useTunnelbroker } from '../tunnelbroker/tunnelbroker-context.js';
import { relationshipActions } from '../types/relationship-types.js';
-import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { getMessageForException } from '../utils/errors.js';
import { useDispatchActionPromise } from '../utils/redux-promise-utils.js';
import { useSelector } from '../utils/redux-utils.js';
@@ -48,7 +47,7 @@
const currentUserInfo = useSelector(state => state.currentUserInfo);
const loggedInToAuthKeyserver = useSelector(
- isLoggedInToKeyserver(authoritativeKeyserverID()),
+ isLoggedInToAuthoritativeKeyserver,
);
React.useEffect(() => {
diff --git a/lib/selectors/user-selectors.js b/lib/selectors/user-selectors.js
--- a/lib/selectors/user-selectors.js
+++ b/lib/selectors/user-selectors.js
@@ -28,6 +28,7 @@
AccountUserInfo,
CurrentUserInfo,
} from '../types/user-types.js';
+import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { entries, values } from '../utils/objects.js';
// Used for specific message payloads that include an array of user IDs, ie.
@@ -167,6 +168,9 @@
},
);
+const isLoggedInToAuthoritativeKeyserver: (state: BaseAppState<>) => boolean =
+ isLoggedInToKeyserver(authoritativeKeyserverID());
+
const usersWithPersonalThreadSelector: (
state: BaseAppState<>,
) => $ReadOnlySet<string> = createSelector(
@@ -267,6 +271,7 @@
userInfoSelectorForPotentialMembers,
isLoggedIn,
isLoggedInToKeyserver,
+ isLoggedInToAuthoritativeKeyserver,
usersWithPersonalThreadSelector,
savedEmojiAvatarSelectorForCurrentUser,
getRelativeUserIDs,
diff --git a/native/account/logged-out-modal.react.js b/native/account/logged-out-modal.react.js
--- a/native/account/logged-out-modal.react.js
+++ b/native/account/logged-out-modal.react.js
@@ -22,8 +22,10 @@
import { SafeAreaView } from 'react-native-safe-area-context';
import { setActiveSessionRecoveryActionType } from 'lib/keyserver-conn/keyserver-conn-types.js';
-import { cookieSelector } from 'lib/selectors/keyserver-selectors.js';
-import { isLoggedIn } from 'lib/selectors/user-selectors.js';
+import {
+ isLoggedIn,
+ isLoggedInToAuthoritativeKeyserver,
+} from 'lib/selectors/user-selectors.js';
import { recoveryFromReduxActionSources } from 'lib/types/account-types.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
@@ -424,7 +426,9 @@
const rehydrateConcluded = useSelector(
state => !!(state._persist && state._persist.rehydrated && navContext),
);
- const cookie = useSelector(cookieSelector(authoritativeKeyserverID));
+ const isLoggedInToAuthKeyserver = useSelector(
+ isLoggedInToAuthoritativeKeyserver,
+ );
const loggedIn = useSelector(isLoggedIn);
const dispatch = useDispatch();
React.useEffect(() => {
@@ -439,8 +443,7 @@
return;
}
- const hasUserCookie = cookie && cookie.startsWith('user=');
- if (loggedIn === !!hasUserCookie) {
+ if (loggedIn === isLoggedInToAuthKeyserver) {
return;
}
@@ -454,7 +457,7 @@
keyserverID: authoritativeKeyserverID,
},
});
- }, [rehydrateConcluded, loggedIn, cookie, dispatch]);
+ }, [rehydrateConcluded, loggedIn, isLoggedInToAuthKeyserver, dispatch]);
const onPressSIWE = React.useCallback(() => {
combinedSetMode('siwe');
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
@@ -15,7 +15,7 @@
import { useKeyserverAuthWithRetry } from 'lib/keyserver-conn/keyserver-auth.js';
import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js';
import { usePreRequestUserState } from 'lib/selectors/account-selectors.js';
-import { isLoggedInToKeyserver } from 'lib/selectors/user-selectors.js';
+import { isLoggedInToAuthoritativeKeyserver } from 'lib/selectors/user-selectors.js';
import {
type LegacyLogInStartingPayload,
logInActionSources,
@@ -543,14 +543,14 @@
const uploadSelectedMedia = useUploadSelectedMedia();
const nativeSetUserAvatar = useNativeSetUserAvatar();
- const isLoggedInToAuthoritativeKeyserver = useSelector(
- isLoggedInToKeyserver(authoritativeKeyserverID),
+ const isLoggedInToAuthKeyserver = useSelector(
+ isLoggedInToAuthoritativeKeyserver,
);
const avatarBeingSetRef = React.useRef(false);
React.useEffect(() => {
if (
- !isLoggedInToAuthoritativeKeyserver ||
+ !isLoggedInToAuthKeyserver ||
currentStep.step !== 'authoritative_keyserver_registration_dispatched' ||
avatarBeingSetRef.current
) {
@@ -600,7 +600,7 @@
})();
}, [
currentStep,
- isLoggedInToAuthoritativeKeyserver,
+ isLoggedInToAuthKeyserver,
uploadSelectedMedia,
nativeSetUserAvatar,
dispatch,
diff --git a/native/components/auto-join-community-handler.react.js b/native/components/auto-join-community-handler.react.js
--- a/native/components/auto-join-community-handler.react.js
+++ b/native/components/auto-join-community-handler.react.js
@@ -10,12 +10,11 @@
import { NeynarClientContext } from 'lib/components/neynar-client-provider.react.js';
import blobService from 'lib/facts/blob-service.js';
import { extractKeyserverIDFromID } from 'lib/keyserver-conn/keyserver-call-utils.js';
-import { cookieSelector } from 'lib/selectors/keyserver-selectors.js';
+import { isLoggedInToAuthoritativeKeyserver } from 'lib/selectors/user-selectors.js';
import { farcasterChannelTagBlobHash } from 'lib/shared/community-utils.js';
import type { AuthMetadata } from 'lib/shared/identity-client-context.js';
import { IdentityClientContext } from 'lib/shared/identity-client-context.js';
import { defaultThreadSubscription } from 'lib/types/subscription-types.js';
-import { authoritativeKeyserverID } from 'lib/utils/authoritative-keyserver.js';
import { getBlobFetchableURL } from 'lib/utils/blob-service.js';
import { useCurrentUserFID } from 'lib/utils/farcaster-utils.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
@@ -31,10 +30,11 @@
function AutoJoinCommunityHandler(): React.Node {
const isActive = useSelector(state => state.lifecycleState !== 'background');
- const cookie = useSelector(cookieSelector(authoritativeKeyserverID()));
- const hasUserCookie = !!(cookie && cookie.startsWith('user='));
+ const isLoggedInToAuthKeyserver = useSelector(
+ isLoggedInToAuthoritativeKeyserver,
+ );
const currentUserID = useSelector(state => state.currentUserInfo?.id);
- const loggedIn = !!currentUserID && hasUserCookie;
+ const loggedIn = !!currentUserID && isLoggedInToAuthKeyserver;
const fid = useCurrentUserFID();
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
@@ -4,12 +4,11 @@
import * as React from 'react';
import { recordAlertActionType } from 'lib/actions/alert-actions.js';
-import { cookieSelector } from 'lib/selectors/keyserver-selectors.js';
+import { isLoggedInToAuthoritativeKeyserver } from 'lib/selectors/user-selectors.js';
import {
alertTypes,
type RecordAlertActionPayload,
} from 'lib/types/alert-types.js';
-import { authoritativeKeyserverID } from 'lib/utils/authoritative-keyserver.js';
import { useCurrentUserFID } from 'lib/utils/farcaster-utils.js';
import { shouldSkipConnectFarcasterAlert } from 'lib/utils/push-alerts.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
@@ -23,10 +22,11 @@
const isActive = useSelector(state => state.lifecycleState !== 'background');
+ const isLoggedInToAuthKeyserver = useSelector(
+ isLoggedInToAuthoritativeKeyserver,
+ );
const currentUserID = useSelector(state => state.currentUserInfo?.id);
- const cookie = useSelector(cookieSelector(authoritativeKeyserverID()));
- const hasUserCookie = !!(cookie && cookie.startsWith('user='));
- const loggedIn = !!currentUserID && hasUserCookie;
+ const loggedIn = !!currentUserID && isLoggedInToAuthKeyserver;
const fid = useCurrentUserFID();
diff --git a/native/navigation/navigation-handler.react.js b/native/navigation/navigation-handler.react.js
--- a/native/navigation/navigation-handler.react.js
+++ b/native/navigation/navigation-handler.react.js
@@ -2,8 +2,10 @@
import * as React from 'react';
-import { cookieSelector } from 'lib/selectors/keyserver-selectors.js';
-import { isLoggedIn } from 'lib/selectors/user-selectors.js';
+import {
+ isLoggedIn,
+ isLoggedInToAuthoritativeKeyserver,
+} from 'lib/selectors/user-selectors.js';
import { logInActionType, logOutActionType } from './action-types.js';
import ModalPruner from './modal-pruner.react.js';
@@ -13,7 +15,6 @@
import PolicyAcknowledgmentHandler from './policy-acknowledgment-handler.react.js';
import ThreadScreenTracker from './thread-screen-tracker.react.js';
import { MissingRegistrationDataHandler } from '../account/registration/missing-registration-data/missing-registration-data-handler.react.js';
-import { authoritativeKeyserverID } from '../authoritative-keyserver.js';
import DevTools from '../redux/dev-tools.react.js';
import { useSelector } from '../redux/redux-utils.js';
import { usePersistedStateLoaded } from '../selectors/app-state-selectors.js';
@@ -63,10 +64,11 @@
const hasCurrentUserInfo = useSelector(isLoggedIn);
- const cookie = useSelector(cookieSelector(authoritativeKeyserverID));
- const hasUserCookie = !!(cookie && cookie.startsWith('user='));
+ const isLoggedInToAuthKeyserver = useSelector(
+ isLoggedInToAuthoritativeKeyserver,
+ );
- const loggedIn = hasCurrentUserInfo && hasUserCookie;
+ const loggedIn = hasCurrentUserInfo && isLoggedInToAuthKeyserver;
const navLoggedIn = useIsAppLoggedIn();
const prevLoggedInRef = React.useRef<?boolean>();

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 11:27 AM (21 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2575177
Default Alt Text
D12696.diff (12 KB)

Event Timeline