-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lib][native][web] Introduce useUpdateRelationships
Summary: This diff updates the `updateRelationships` action function to use the new `update_relationships2` API, and introduces `useUpdateRelationships`, a new hook that abstracts some complexity and in following diffs will handle forking between thick/thread logic. Depends on D13440 Test Plan: I tested this new endpoint as part of my testing of [ENG-9269](https://linear.app/comm/issue/ENG-9269/relationship-buttons-result-in-a-thin-thread-being-created) Reviewers: tomek Reviewed By: tomek Differential Revision: https://phab.comm.dev/D13441
- Loading branch information
Showing
11 changed files
with
100 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.