Page MenuHomePhabricator

D13441.id44475.diff
No OneTemporary

D13441.id44475.diff

diff --git a/lib/actions/relationship-actions.js b/lib/actions/relationship-actions.js
--- a/lib/actions/relationship-actions.js
+++ b/lib/actions/relationship-actions.js
@@ -3,7 +3,7 @@
import type { CallSingleKeyserverEndpoint } from '../keyserver-conn/call-single-keyserver-endpoint.js';
import type {
RelationshipErrors,
- LegacyRelationshipRequest,
+ RelationshipRequest,
} from '../types/relationship-types.js';
import { ServerError } from '../utils/errors.js';
@@ -15,10 +15,10 @@
const updateRelationships =
(
callSingleKeyserverEndpoint: CallSingleKeyserverEndpoint,
- ): ((request: LegacyRelationshipRequest) => Promise<RelationshipErrors>) =>
+ ): ((request: RelationshipRequest) => Promise<RelationshipErrors>) =>
async request => {
const errors = await callSingleKeyserverEndpoint(
- 'update_relationships',
+ 'update_relationships2',
request,
);
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
@@ -3,15 +3,12 @@
import * as React from 'react';
import { setAuxUserFIDsActionType } from '../actions/aux-user-actions.js';
-import {
- updateRelationships as serverUpdateRelationships,
- updateRelationshipsActionTypes,
-} from '../actions/relationship-actions.js';
+import { updateRelationshipsActionTypes } from '../actions/relationship-actions.js';
import { setSyncedMetadataEntryActionType } from '../actions/synced-metadata-actions.js';
import { useFindUserIdentities } from '../actions/user-actions.js';
import { NeynarClientContext } from '../components/neynar-client-provider.react.js';
import { useIsLoggedInToIdentityAndAuthoritativeKeyserver } from '../hooks/account-hooks.js';
-import { useLegacyAshoatKeyserverCall } from '../keyserver-conn/legacy-keyserver-call.js';
+import { useUpdateRelationships } from '../hooks/relationship-hooks.js';
import { IdentityClientContext } from '../shared/identity-client-context.js';
import { relationshipActions } from '../types/relationship-types.js';
import { syncedMetadataNames } from '../types/synced-metadata-types.js';
@@ -43,15 +40,11 @@
const dispatch = useDispatch();
const dispatchActionPromise = useDispatchActionPromise();
- const updateRelationships = useLegacyAshoatKeyserverCall(
- serverUpdateRelationships,
- );
+
+ const updateRelationships = useUpdateRelationships();
const createThreadsAndRobotextForFarcasterMutuals = React.useCallback(
- (userIDsToFID: { +[userID: string]: string }) =>
- updateRelationships({
- action: relationshipActions.FARCASTER_MUTUAL,
- userIDsToFID,
- }),
+ (userIDs: $ReadOnlyArray<string>) =>
+ updateRelationships(relationshipActions.FARCASTER_MUTUAL, userIDs),
[updateRelationships],
);
@@ -100,14 +93,7 @@
return;
}
- const userIDsToFID: { +[userID: string]: string } = Object.fromEntries(
- newCommUsers.map(({ userID, farcasterID }) => [userID, farcasterID]),
- );
-
- const userIDsToFIDIncludingCurrentUser: { +[userID: string]: string } = {
- ...userIDsToFID,
- [(currentUserID: string)]: fid,
- };
+ const newCommUserIDs = newCommUsers.map(({ userID }) => userID);
if (!loggedInRef.current) {
return;
@@ -115,9 +101,7 @@
void dispatchActionPromise(
updateRelationshipsActionTypes,
- createThreadsAndRobotextForFarcasterMutuals(
- userIDsToFIDIncludingCurrentUser,
- ),
+ createThreadsAndRobotextForFarcasterMutuals(newCommUserIDs),
);
}, [
isActive,
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
@@ -3,17 +3,14 @@
import invariant from 'invariant';
import * as React from 'react';
-import {
- updateRelationships,
- updateRelationshipsActionTypes,
-} from '../actions/relationship-actions.js';
+import { updateRelationshipsActionTypes } from '../actions/relationship-actions.js';
import {
useFindUserIdentities,
findUserIdentitiesActionTypes,
} from '../actions/user-actions.js';
import { useIsLoggedInToAuthoritativeKeyserver } from '../hooks/account-hooks.js';
import { useGetAndUpdateDeviceListsForUsers } from '../hooks/peer-list-hooks.js';
-import { useLegacyAshoatKeyserverCall } from '../keyserver-conn/legacy-keyserver-call.js';
+import { useUpdateRelationships } from '../hooks/relationship-hooks.js';
import { usersWithMissingDeviceListSelector } from '../selectors/user-selectors.js';
import { IdentityClientContext } from '../shared/identity-client-context.js';
import { useTunnelbroker } from '../tunnelbroker/tunnelbroker-context.js';
@@ -46,8 +43,7 @@
const requestedIDsRef = React.useRef(new Set<string>());
const requestedAvatarsRef = React.useRef(new Set<string>());
- const callUpdateRelationships =
- useLegacyAshoatKeyserverCall(updateRelationships);
+ const updateRelationships = useUpdateRelationships();
const currentUserInfo = useSelector(state => state.currentUserInfo);
@@ -107,10 +103,10 @@
const updateRelationshipsPromise = (async () => {
try {
- return await callUpdateRelationships({
- action: relationshipActions.ACKNOWLEDGE,
- userIDs: userIDsWithoutOwnID,
- });
+ return await updateRelationships(
+ relationshipActions.ACKNOWLEDGE,
+ userIDsWithoutOwnID,
+ );
} catch (e) {
if (e instanceof FetchTimeout) {
userIDsWithoutOwnID.forEach(id =>
@@ -129,7 +125,7 @@
})();
}, [
getAuthMetadata,
- callUpdateRelationships,
+ updateRelationships,
currentUserInfo?.id,
dispatchActionPromise,
findUserIdentities,
diff --git a/lib/hooks/relationship-hooks.js b/lib/hooks/relationship-hooks.js
new file mode 100644
--- /dev/null
+++ b/lib/hooks/relationship-hooks.js
@@ -0,0 +1,36 @@
+// @flow
+
+import * as React from 'react';
+
+import { updateRelationships as serverUpdateRelationships } from '../actions/relationship-actions.js';
+import { useLegacyAshoatKeyserverCall } from '../keyserver-conn/legacy-keyserver-call.js';
+import type {
+ RelationshipAction,
+ RelationshipErrors,
+} from '../types/relationship-types.js';
+
+function useUpdateRelationships(): (
+ action: RelationshipAction,
+ userIDs: $ReadOnlyArray<string>,
+) => Promise<RelationshipErrors> {
+ const updateRelationships = useLegacyAshoatKeyserverCall(
+ serverUpdateRelationships,
+ );
+ return React.useCallback(
+ (action: RelationshipAction, userIDs: $ReadOnlyArray<string>) =>
+ updateRelationships({
+ action,
+ users: Object.fromEntries(
+ userIDs.map(userID => [
+ userID,
+ {
+ createRobotextInThinThread: true,
+ },
+ ]),
+ ),
+ }),
+ [updateRelationships],
+ );
+}
+
+export { useUpdateRelationships };
diff --git a/lib/hooks/relationship-prompt.js b/lib/hooks/relationship-prompt.js
--- a/lib/hooks/relationship-prompt.js
+++ b/lib/hooks/relationship-prompt.js
@@ -3,11 +3,8 @@
import invariant from 'invariant';
import * as React from 'react';
-import {
- updateRelationships as serverUpdateRelationships,
- updateRelationshipsActionTypes,
-} from '../actions/relationship-actions.js';
-import { useLegacyAshoatKeyserverCall } from '../keyserver-conn/legacy-keyserver-call.js';
+import { updateRelationshipsActionTypes } from '../actions/relationship-actions.js';
+import { useUpdateRelationships } from '../hooks/relationship-hooks.js';
import { getSingleOtherUser } from '../shared/thread-utils.js';
import type { ThreadInfo } from '../types/minimally-encoded-thread-permissions-types.js';
import {
@@ -84,9 +81,7 @@
const [isLoadingUnfriendUser, setIsLoadingUnfriendUser] =
React.useState(false);
- const callUpdateRelationships = useLegacyAshoatKeyserverCall(
- serverUpdateRelationships,
- );
+ const updateRelationships = useUpdateRelationships();
const updateRelationship = React.useCallback(
async (
action: TraditionalRelationshipAction,
@@ -95,10 +90,7 @@
try {
setInProgress(true);
invariant(otherUserID, 'Other user info id should be present');
- return await callUpdateRelationships({
- action,
- userIDs: [otherUserID],
- });
+ return await updateRelationships(action, [otherUserID]);
} catch (e) {
onErrorCallback?.();
throw e;
@@ -106,7 +98,7 @@
setInProgress(false);
}
},
- [callUpdateRelationships, onErrorCallback, otherUserID],
+ [updateRelationships, onErrorCallback, otherUserID],
);
const dispatchActionPromise = useDispatchActionPromise();
diff --git a/native/chat/settings/thread-settings-edit-relationship.react.js b/native/chat/settings/thread-settings-edit-relationship.react.js
--- a/native/chat/settings/thread-settings-edit-relationship.react.js
+++ b/native/chat/settings/thread-settings-edit-relationship.react.js
@@ -4,12 +4,9 @@
import * as React from 'react';
import { Text, View } from 'react-native';
-import {
- updateRelationships as serverUpdateRelationships,
- updateRelationshipsActionTypes,
-} from 'lib/actions/relationship-actions.js';
+import { updateRelationshipsActionTypes } from 'lib/actions/relationship-actions.js';
import { useENSNames } from 'lib/hooks/ens-cache.js';
-import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js';
+import { useUpdateRelationships } from 'lib/hooks/relationship-hooks.js';
import {
getRelationshipActionText,
getRelationshipDispatchAction,
@@ -49,16 +46,11 @@
const [otherUserInfo] = useENSNames([otherUserInfoFromRedux]);
- const callUpdateRelationships = useLegacyAshoatKeyserverCall(
- serverUpdateRelationships,
- );
+ const updateRelationships = useUpdateRelationships();
const updateRelationship = React.useCallback(
async (action: TraditionalRelationshipAction) => {
try {
- return await callUpdateRelationships({
- action,
- userIDs: [otherUserInfo.id],
- });
+ return await updateRelationships(action, [otherUserInfo.id]);
} catch (e) {
Alert.alert(
unknownErrorAlertDetails.title,
@@ -71,7 +63,7 @@
throw e;
}
},
- [callUpdateRelationships, otherUserInfo],
+ [updateRelationships, otherUserInfo],
);
const { relationshipButton } = props;
diff --git a/native/profile/relationship-list-item.react.js b/native/profile/relationship-list-item.react.js
--- a/native/profile/relationship-list-item.react.js
+++ b/native/profile/relationship-list-item.react.js
@@ -4,11 +4,8 @@
import * as React from 'react';
import { View, Text, TouchableOpacity, ActivityIndicator } from 'react-native';
-import {
- updateRelationshipsActionTypes,
- updateRelationships,
-} from 'lib/actions/relationship-actions.js';
-import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js';
+import { updateRelationshipsActionTypes } from 'lib/actions/relationship-actions.js';
+import { useUpdateRelationships } from 'lib/hooks/relationship-hooks.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import type { LoadingStatus } from 'lib/types/loading-types.js';
import type { ReactRef } from 'lib/types/react-types.js';
@@ -17,7 +14,7 @@
type RelationshipErrors,
userRelationshipStatus,
relationshipActions,
- type LegacyRelationshipRequest,
+ type RelationshipAction,
} from 'lib/types/relationship-types.js';
import type {
AccountUserInfo,
@@ -111,7 +108,8 @@
+dispatchActionPromise: DispatchActionPromise,
// async functions that hit server APIs
+updateRelationships: (
- request: LegacyRelationshipRequest,
+ action: RelationshipAction,
+ userIDs: $ReadOnlyArray<string>,
) => Promise<RelationshipErrors>,
// withOverlayContext
+overlayContext: ?OverlayContextType,
@@ -306,10 +304,9 @@
action: TraditionalRelationshipAction,
): Promise<RelationshipErrors> {
try {
- return await this.props.updateRelationships({
- action,
- userIDs: [this.props.userInfo.id],
- });
+ return await this.props.updateRelationships(action, [
+ this.props.userInfo.id,
+ ]);
} catch (e) {
Alert.alert(
unknownErrorAlertDetails.title,
@@ -337,8 +334,7 @@
const colors = useColors();
const styles = useStyles(unboundStyles);
const dispatchActionPromise = useDispatchActionPromise();
- const boundUpdateRelationships =
- useLegacyAshoatKeyserverCall(updateRelationships);
+ const updateRelationships = useUpdateRelationships();
const overlayContext = React.useContext(OverlayContext);
const keyboardState = React.useContext(KeyboardContext);
@@ -352,7 +348,7 @@
colors={colors}
styles={styles}
dispatchActionPromise={dispatchActionPromise}
- updateRelationships={boundUpdateRelationships}
+ updateRelationships={updateRelationships}
overlayContext={overlayContext}
keyboardState={keyboardState}
navigateToUserProfileBottomSheet={navigateToUserProfileBottomSheet}
diff --git a/native/profile/relationship-list.react.js b/native/profile/relationship-list.react.js
--- a/native/profile/relationship-list.react.js
+++ b/native/profile/relationship-list.react.js
@@ -5,12 +5,9 @@
import { View, Text, Platform } from 'react-native';
import { FlatList } from 'react-native-gesture-handler';
-import {
- updateRelationshipsActionTypes,
- updateRelationships,
-} from 'lib/actions/relationship-actions.js';
+import { updateRelationshipsActionTypes } from 'lib/actions/relationship-actions.js';
import { useENSNames } from 'lib/hooks/ens-cache.js';
-import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js';
+import { useUpdateRelationships } from 'lib/hooks/relationship-hooks.js';
import { registerFetchKey } from 'lib/reducers/loading-reducer.js';
import { useUserSearchIndex } from 'lib/selectors/nav-selectors.js';
import { userRelationshipsSelector } from 'lib/selectors/relationship-selectors.js';
@@ -200,8 +197,7 @@
tagInputRef.current?.focus();
}, []);
- const callUpdateRelationships =
- useLegacyAshoatKeyserverCall(updateRelationships);
+ const updateRelationships = useUpdateRelationships();
const updateRelationshipsOnServer = React.useCallback(async () => {
const action = {
[FriendListRouteName]: relationshipActions.FRIEND,
@@ -209,10 +205,7 @@
}[routeName];
const userIDs = currentTags.map(userInfo => userInfo.id);
try {
- const result = await callUpdateRelationships({
- action,
- userIDs,
- });
+ const result = await updateRelationships(action, userIDs);
setCurrentTags([]);
setSearchInputText('');
return result;
@@ -228,7 +221,7 @@
}, [
routeName,
currentTags,
- callUpdateRelationships,
+ updateRelationships,
onUnknownErrorAlertAcknowledged,
]);
diff --git a/native/profile/user-relationship-tooltip-modal.react.js b/native/profile/user-relationship-tooltip-modal.react.js
--- a/native/profile/user-relationship-tooltip-modal.react.js
+++ b/native/profile/user-relationship-tooltip-modal.react.js
@@ -3,11 +3,8 @@
import * as React from 'react';
import { TouchableOpacity } from 'react-native';
-import {
- updateRelationshipsActionTypes,
- updateRelationships,
-} from 'lib/actions/relationship-actions.js';
-import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js';
+import { updateRelationshipsActionTypes } from 'lib/actions/relationship-actions.js';
+import { useUpdateRelationships } from 'lib/hooks/relationship-hooks.js';
import { stringForUser } from 'lib/shared/user-utils.js';
import type { RelativeUserInfo } from 'lib/types/user-types.js';
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
@@ -39,18 +36,16 @@
+action: Action,
};
function useRelationshipAction(input: OnRemoveUserProps) {
- const boundRemoveRelationships =
- useLegacyAshoatKeyserverCall(updateRelationships);
+ const updateRelationships = useUpdateRelationships();
const dispatchActionPromise = useDispatchActionPromise();
const userText = stringForUser(input.relativeUserInfo);
return React.useCallback(() => {
const callRemoveRelationships = async () => {
try {
- return await boundRemoveRelationships({
- action: input.action,
- userIDs: [input.relativeUserInfo.id],
- });
+ return await updateRelationships(input.action, [
+ input.relativeUserInfo.id,
+ ]);
} catch (e) {
Alert.alert(
unknownErrorAlertDetails.title,
@@ -90,7 +85,7 @@
],
{ cancelable: true },
);
- }, [boundRemoveRelationships, dispatchActionPromise, userText, input]);
+ }, [updateRelationships, dispatchActionPromise, userText, input]);
}
function TooltipMenu(
diff --git a/web/modals/threads/settings/thread-settings-relationship-button.react.js b/web/modals/threads/settings/thread-settings-relationship-button.react.js
--- a/web/modals/threads/settings/thread-settings-relationship-button.react.js
+++ b/web/modals/threads/settings/thread-settings-relationship-button.react.js
@@ -9,11 +9,8 @@
import invariant from 'invariant';
import * as React from 'react';
-import {
- updateRelationships,
- updateRelationshipsActionTypes,
-} from 'lib/actions/relationship-actions.js';
-import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js';
+import { updateRelationshipsActionTypes } from 'lib/actions/relationship-actions.js';
+import { useUpdateRelationships } from 'lib/hooks/relationship-hooks.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import {
getRelationshipActionText,
@@ -104,21 +101,17 @@
}, [relationshipButton]);
const dispatchActionPromise = useDispatchActionPromise();
- const callUpdateRelationships =
- useLegacyAshoatKeyserverCall(updateRelationships);
+ const updateRelationships = useUpdateRelationships();
const updateRelationshipsActionPromise = React.useCallback(async () => {
try {
setErrorMessage?.('');
- return await callUpdateRelationships({
- action,
- userIDs: [otherUserInfo.id],
- });
+ return await updateRelationships(action, [otherUserInfo.id]);
} catch (e) {
setErrorMessage?.('Error updating relationship');
throw e;
}
- }, [action, callUpdateRelationships, otherUserInfo.id, setErrorMessage]);
+ }, [action, updateRelationships, otherUserInfo.id, setErrorMessage]);
const onClick = React.useCallback(() => {
void dispatchActionPromise(
updateRelationshipsActionTypes,
diff --git a/web/settings/relationship/add-users-list-modal.react.js b/web/settings/relationship/add-users-list-modal.react.js
--- a/web/settings/relationship/add-users-list-modal.react.js
+++ b/web/settings/relationship/add-users-list-modal.react.js
@@ -2,12 +2,9 @@
import * as React from 'react';
-import {
- updateRelationships,
- updateRelationshipsActionTypes,
-} from 'lib/actions/relationship-actions.js';
+import { updateRelationshipsActionTypes } from 'lib/actions/relationship-actions.js';
import { useModalContext } from 'lib/components/modal-provider.react.js';
-import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js';
+import { useUpdateRelationships } from 'lib/hooks/relationship-hooks.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import type {
UserRelationshipStatus,
@@ -90,18 +87,17 @@
[excludedStatuses],
);
- const callUpdateRelationships =
- useLegacyAshoatKeyserverCall(updateRelationships);
+ const updateRelationships = useUpdateRelationships();
const dispatchActionPromise = useDispatchActionPromise();
const updateRelationshipsPromiseCreator = React.useCallback(async () => {
try {
setErrorMessage('');
- const result = await callUpdateRelationships({
- action: relationshipAction,
- userIDs: Array.from(pendingUsersToAdd.keys()),
- });
+ const result = await updateRelationships(
+ relationshipAction,
+ Array.from(pendingUsersToAdd.keys()),
+ );
popModal();
return result;
} catch (e) {
@@ -110,7 +106,7 @@
}
}, [
setErrorMessage,
- callUpdateRelationships,
+ updateRelationships,
relationshipAction,
pendingUsersToAdd,
popModal,

File Metadata

Mime Type
text/plain
Expires
Sun, Oct 20, 5:40 AM (19 h, 52 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2318075
Default Alt Text
D13441.id44475.diff (20 KB)

Event Timeline