From fdd4d22cab5f555f981ba922f5fef9731dbe9e9d Mon Sep 17 00:00:00 2001 From: Shravya Ramesh Date: Tue, 23 Feb 2021 08:38:20 -0800 Subject: added frind button --- src/utils/friends.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/utils') 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; +}; -- cgit v1.2.3-70-g09d2