|
@@ -234,7 +234,7 @@ export const actionAddlike = _id =>
|
|
|
}
|
|
|
}))
|
|
|
|
|
|
-export const actionSubscribe = (userId,followId) =>
|
|
|
+export const actionSubscribe = (userId,followId,oldFollow) =>
|
|
|
actionPromise('subscribe', gql(`mutation Subscribe($user:UserInput){
|
|
|
UserUpsert(user:$user){
|
|
|
following{_id, nick}
|
|
@@ -243,15 +243,53 @@ export const actionSubscribe = (userId,followId) =>
|
|
|
{
|
|
|
user: {
|
|
|
"_id": userId,
|
|
|
- "following": {"_id":followId}
|
|
|
+ "following": [...(oldFollow || []), {"_id":followId}]
|
|
|
}
|
|
|
}))
|
|
|
export const actionFullSubscribe = (userId,followId) => async(dispatch,getState) => {
|
|
|
-
|
|
|
- let followingId = await dispatch(actionSubscribe(userId,followId));
|
|
|
+ const oldFollowing = (getState().promise.aboutMe?.payload?.following || []).map(item => ({
|
|
|
+ _id: item._id
|
|
|
+ }))
|
|
|
+ let followingId = await dispatch(actionSubscribe(userId,followId, oldFollowing));
|
|
|
if(followingId){
|
|
|
await dispatch(actionAboutUser(followId))
|
|
|
await dispatch(actionAboutMe(userId))
|
|
|
}
|
|
|
|
|
|
-}
|
|
|
+}
|
|
|
+
|
|
|
+export const actionUnSubscribe = (userId,oldFollow) =>
|
|
|
+ actionPromise('unSubscribe', gql(`mutation UnSubscribe($user:UserInput){
|
|
|
+ UserUpsert(user:$user){
|
|
|
+ following{_id}
|
|
|
+ }
|
|
|
+ }`, {
|
|
|
+ user: {
|
|
|
+ "_id": userId,
|
|
|
+ "following":[...oldFollow]
|
|
|
+ }
|
|
|
+ }))
|
|
|
+export const actionFullUnSubscribe = (userId, followId) => async(dispatch,getState)=> {
|
|
|
+ const oldFollowing = (getState().promise.aboutMe?.payload?.following || []).filter(item => item._id !==followId)
|
|
|
+ const oldFollow = (oldFollowing || []).map(item => ({
|
|
|
+ _id: item._id
|
|
|
+ }))
|
|
|
+ if(oldFollow){
|
|
|
+ await dispatch(actionUnSubscribe(userId, oldFollow))
|
|
|
+ await dispatch(actionAboutUser(followId));
|
|
|
+ await dispatch(actionAboutMe(userId));
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+export const actionDeleteLike = (_id) =>
|
|
|
+ actionPromise('unLike', gql(`mutation Deletelike($like:LikeInput){
|
|
|
+ LikeDelete(like:$like){
|
|
|
+ _id
|
|
|
+ }
|
|
|
+ }`,{
|
|
|
+ like:{
|
|
|
+ _id
|
|
|
+ }
|
|
|
+ }))
|
|
|
+
|
|
|
+/* export const actionfullDeleteLike = (_id) => */
|