diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-03-18 19:48:53 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-03-18 19:48:53 -0400 |
| commit | aa0ddb7c5a6612ff067f7dce1c6d5b083db44309 (patch) | |
| tree | 89326275ce5ff4e48bc29952c60856258cd8b0ab /src/store | |
| parent | 07a15098625786451270e30e61e2d6e78c02d4db (diff) | |
| parent | 9a7e34bf992e0bfa3b9ce7d83643d97fad209e6e (diff) | |
Merge pull request #303 from shravyaramesh/add-friends-thru-contacts
[TMA-622] Add friends from contacts
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) { |
