diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-03-24 13:25:29 -0400 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-03-24 13:25:29 -0400 |
| commit | cc1b5a0be911dc05386a5114e966b7ee4eb21441 (patch) | |
| tree | 90fad5a8ed92206b3026e8fd033b4d35360884f7 /src/store | |
| parent | 96477697afe4dd92ce68f0f778decbca30d83e77 (diff) | |
| parent | 33c107f7382955f6993d8415f08262f51060d178 (diff) | |
Merge branch 'master' into tma698-api-profile
# Conflicts:
# src/components/search/SearchBar.tsx
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) { |
