aboutsummaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-03-24 13:25:29 -0400
committerIvan Chen <ivan@tagg.id>2021-03-24 13:25:29 -0400
commitcc1b5a0be911dc05386a5114e966b7ee4eb21441 (patch)
tree90fad5a8ed92206b3026e8fd033b4d35360884f7 /src/store
parent96477697afe4dd92ce68f0f778decbca30d83e77 (diff)
parent33c107f7382955f6993d8415f08262f51060d178 (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.ts21
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) {