diff options
| author | Shravya Ramesh <shravs1208@gmail.com> | 2021-03-18 02:06:02 -0700 |
|---|---|---|
| committer | Shravya Ramesh <shravs1208@gmail.com> | 2021-03-18 02:06:02 -0700 |
| commit | 1080adb75c18f6da6b91be4264c69a9bf908ff0d (patch) | |
| tree | c29ea0a0e3be6f14d64057796ddb5b853426f070 /src/store | |
| parent | 8569dafb631d99f325236fb7a134a0087d95b212 (diff) | |
works
Diffstat (limited to 'src/store')
| -rw-r--r-- | src/store/actions/userFriends.ts | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/store/actions/userFriends.ts b/src/store/actions/userFriends.ts index 4f55acc8..9da3cb4a 100644 --- a/src/store/actions/userFriends.ts +++ b/src/store/actions/userFriends.ts @@ -1,4 +1,4 @@ -import {getTokenOrLogout} from '../../utils'; +import {getTokenOrLogout, userXInStore} from '../../utils'; import {RootState} from '../rootReducer'; import { FriendshipStatusType, @@ -90,6 +90,7 @@ export const friendUnfriendUser = ( export const addFriend = ( friend: ProfilePreviewType, // userX's profile preview screenType: ScreenType, //screentype from content + state: RootState, ): ThunkAction< Promise<boolean | undefined>, RootState, @@ -100,14 +101,16 @@ export const addFriend = ( const token = await getTokenOrLogout(dispatch); const success = await addFriendService(friend.id, token); if (success) { - dispatch({ - type: userXFriendshipEdited.type, - payload: { - userId: friend.id, - screenType, - data: 'requested', - }, - }); + if (userXInStore(state, screenType, friend.id)) { + dispatch({ + type: userXFriendshipEdited.type, + payload: { + userId: friend.id, + screen: screenType, + data: 'requested', + }, + }); + } return true; } } catch (error) { |
