aboutsummaryrefslogtreecommitdiff
path: root/src/store/reducers
diff options
context:
space:
mode:
authorIvan Chen <ivan@tagg.id>2021-02-05 17:35:05 -0500
committerIvan Chen <ivan@tagg.id>2021-02-05 17:35:05 -0500
commit231fed8c645dc29334b946dccca94fbb13116fe2 (patch)
treefc7bcd0f9e11b943d89877c621e95681e89a18d7 /src/store/reducers
parenta5f746525df9bb2967c252b70e7a4e2f9daa2b8d (diff)
parentbad7fac394f8ef2870a9a139fd46d0def4421bf1 (diff)
Merge branch 'master' into TMA-579-Redesign-Snapchat-Tiktok
# Conflicts: # src/components/common/TaggSquareButton.tsx
Diffstat (limited to 'src/store/reducers')
-rw-r--r--src/store/reducers/userFriendsReducer.ts10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/store/reducers/userFriendsReducer.ts b/src/store/reducers/userFriendsReducer.ts
index 2041a181..92402db1 100644
--- a/src/store/reducers/userFriendsReducer.ts
+++ b/src/store/reducers/userFriendsReducer.ts
@@ -11,8 +11,14 @@ const userFriendsSlice = createSlice({
updateFriends: (state, action) => {
const {isFriend, data} = action.payload;
- if (!isFriend) state.friends.push(data);
- else {
+ if (!isFriend) {
+ const friendInList: boolean = state.friends.some(
+ (friend) => friend.username === data.username,
+ );
+ if (!friendInList) {
+ state.friends.push(data);
+ }
+ } else {
state.friends = state.friends.filter(
(friend) => friend.username !== data.username,
);