aboutsummaryrefslogtreecommitdiff
path: root/src/store/reducers
diff options
context:
space:
mode:
authorAshm Walia <40498934+ashmgarv@users.noreply.github.com>2020-12-30 11:36:44 -0800
committerGitHub <noreply@github.com>2020-12-30 14:36:44 -0500
commit38661e00281363b0f4ad32f0b29d739e1ca09164 (patch)
tree316cd837b6cc6ae24783f1d93d6c9ee7fb898f68 /src/store/reducers
parentbd2f89805d0bb1c2f1d08fe8d91099aa4f109d35 (diff)
[TMA - 457]Change followers to friends (#149)
* One commit to replace followers with friends * Move block unblock to drawer and some cosmetic changes * Options to edit own profile when viewing * Changes for University Class * Small fix * Made ProfileOnboarding a scroll view and other small changes * Small fix * Small fix thanks to ivan and tanmay * Add ?
Diffstat (limited to 'src/store/reducers')
-rw-r--r--src/store/reducers/index.ts2
-rw-r--r--src/store/reducers/userFollowReducer.ts27
-rw-r--r--src/store/reducers/userFriendsReducer.ts25
-rw-r--r--src/store/reducers/userXReducer.ts13
4 files changed, 29 insertions, 38 deletions
diff --git a/src/store/reducers/index.ts b/src/store/reducers/index.ts
index f525eb81..c9463639 100644
--- a/src/store/reducers/index.ts
+++ b/src/store/reducers/index.ts
@@ -1,4 +1,4 @@
-export * from './userFollowReducer';
+export * from './userFriendsReducer';
export * from './userReducer';
export * from './userMomentsReducer';
export * from './userSocialsReducer';
diff --git a/src/store/reducers/userFollowReducer.ts b/src/store/reducers/userFollowReducer.ts
deleted file mode 100644
index 55e16532..00000000
--- a/src/store/reducers/userFollowReducer.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import {createSlice} from '@reduxjs/toolkit';
-import {act} from 'react-test-renderer';
-import {NO_FOLLOW_DATA} from '../initialStates';
-
-const userFollowSlice = createSlice({
- name: 'userFollow',
- initialState: NO_FOLLOW_DATA,
- reducers: {
- userFollowFetched: (state, action) => {
- state.followers = action.payload.followers;
- state.following = action.payload.following;
- },
-
- updateFollowing: (state, action) => {
- const {isFollowed, data} = action.payload;
- if (!isFollowed) state.following.push(data);
- else {
- state.following = state.following.filter(
- (follow) => follow.username !== data.username,
- );
- }
- },
- },
-});
-
-export const {userFollowFetched, updateFollowing} = userFollowSlice.actions;
-export const userFollowReducer = userFollowSlice.reducer;
diff --git a/src/store/reducers/userFriendsReducer.ts b/src/store/reducers/userFriendsReducer.ts
new file mode 100644
index 00000000..2041a181
--- /dev/null
+++ b/src/store/reducers/userFriendsReducer.ts
@@ -0,0 +1,25 @@
+import {createSlice} from '@reduxjs/toolkit';
+import {NO_FRIENDS_DATA} from '../initialStates';
+
+const userFriendsSlice = createSlice({
+ name: 'userFriends',
+ initialState: NO_FRIENDS_DATA,
+ reducers: {
+ userFriendsFetched: (state, action) => {
+ state.friends = action.payload.friends;
+ },
+
+ updateFriends: (state, action) => {
+ const {isFriend, data} = action.payload;
+ if (!isFriend) state.friends.push(data);
+ else {
+ state.friends = state.friends.filter(
+ (friend) => friend.username !== data.username,
+ );
+ }
+ },
+ },
+});
+
+export const {userFriendsFetched, updateFriends} = userFriendsSlice.actions;
+export const userFriendsReducer = userFriendsSlice.reducer;
diff --git a/src/store/reducers/userXReducer.ts b/src/store/reducers/userXReducer.ts
index bb142864..fa1598b2 100644
--- a/src/store/reducers/userXReducer.ts
+++ b/src/store/reducers/userXReducer.ts
@@ -38,16 +38,10 @@ const userXSlice = createSlice({
].moments = action.payload.data;
},
- userXFollowersFetched: (state, action) => {
+ userXFriendsFetched: (state, action) => {
state[<ScreenType>action.payload.screenType][
action.payload.userId
- ].followers = action.payload.data;
- },
-
- userXFollowingFetched: (state, action) => {
- state[<ScreenType>action.payload.screenType][
- action.payload.userId
- ].following = action.payload.data;
+ ].friends = action.payload.data;
},
userXAvatarFetched: (state, action) => {
@@ -80,8 +74,7 @@ export const {
userXUserFetched,
userXRequested,
userXAvatarFetched,
- userXFollowersFetched,
- userXFollowingFetched,
+ userXFriendsFetched,
userXCoverFetched,
userXMomentsFetched,
userXProfileFetched,