aboutsummaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorIvan Chen <ivan@thetaggid.com>2021-02-23 18:51:50 -0500
committerGitHub <noreply@github.com>2021-02-23 18:51:50 -0500
commita586f89ddd40b1954310673cf86f1b953545d720 (patch)
treebd8dd6dc89ee583c8decac25b46170bb3ef792ee /src/utils
parent5864b997b68ae774a871ee9b43c0e548a2656cc6 (diff)
parent9bf53a2251f043396fb536800b49e2cf4f811a66 (diff)
Merge pull request #259 from shravyaramesh/sp-add-friend-button
[TMA-258] Suggested People: Add friend button
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/friends.ts13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/utils/friends.ts b/src/utils/friends.ts
index ba15e087..3398c123 100644
--- a/src/utils/friends.ts
+++ b/src/utils/friends.ts
@@ -4,6 +4,7 @@ import {RootState} from '../store/rootReducer';
import {ProfilePreviewType, ProfileType, ScreenType, UserType} from '../types';
import {AppDispatch} from '../store/configureStore';
import {
+ addFriend,
friendUnfriendUser,
unfriendUser,
updateUserXFriends,
@@ -52,3 +53,15 @@ export const handleUnfriend = async (
await dispatch(updateUserXFriends(friend.id, state));
dispatch(updateUserXProfileAllScreens(friend.id, state));
};
+
+export const handleAddFriend = async (
+ screenType: ScreenType,
+ friend: ProfilePreviewType,
+ dispatch: AppDispatch,
+ state: RootState,
+) => {
+ const success = await dispatch(addFriend(friend, screenType));
+ await dispatch(updateUserXFriends(friend.id, state));
+ await dispatch(updateUserXProfileAllScreens(friend.id, state));
+ return success;
+};