浏览代码

fix clear status upload post, fix onSubscribe, edit action get following, refactoring function changeSubscribe

makstravm 2 年之前
父节点
当前提交
fccf8ed63b
共有 3 个文件被更改,包括 23 次插入20 次删除
  1. 3 9
      src/actions/index.js
  2. 4 2
      src/pages/EntityEditorPost.jsx
  3. 16 9
      src/redux/saga/index.js

+ 3 - 9
src/actions/index.js

@@ -275,24 +275,18 @@ export const actionUpdateFollowersAC = (newResult) => ({ type: 'UPDATE-FOLLOWERS
 export const actionSubscribe = (userId) => ({ type: 'SUBSCRIBE', userId })
 export const actionUnSubscribe = (userId) => ({ type: 'UN_SUBSCRIBE', userId })
 
-export const actionLoadSubscribe = (myID, myFollowing, userId) =>
+export const actionChangeSubscribe = (newFollowing) =>
     actionPromise('subscribe', gql(`mutation following($user:UserInput){
         UserUpsert( user:$user){
             following{_id}
         }
-      }`, { user: { _id: myID, following: [...myFollowing || [], { _id: userId }] } }))
+      }`, { user: newFollowing }))
 
-export const actionloadUnSubscribe = (myID, myFollowing) =>
-    actionPromise('unSubscribe', gql(`mutation followingUn($user:UserInput){
-        UserUpsert( user:$user){
-            following{_id}
-        }
-      }`, { user: { _id: myID, following: [...myFollowing] } }))
 
 export const actionUpdateMyFollowing = (_id) =>
     actionPromise('upDateFollowing', gql(` query followers($id:String!){
         UserFindOne(query: $id){
-                            following {_id nick login}
+                            following {_id}
         }
     }`, { id: JSON.stringify([{ _id }]) }))
 

+ 4 - 2
src/pages/EntityEditorPost.jsx

@@ -2,7 +2,7 @@ import { Button, Divider, message } from "antd"
 import Title from "antd/lib/typography/Title"
 import { useEffect, useState } from "react"
 import { connect } from "react-redux"
-import { actionAddPostAC, actionFullSentPost, actionRemovePostAC, } from "../actions"
+import { actionAddPostAC, actionClearPromise, actionFullSentPost, actionRemovePostAC, } from "../actions"
 import { EditPhotos } from "../components/uploadPhoto/EditPhotos"
 import { EditDescriptionPost } from "../components/uploadPhoto/EditDescriptionPost"
 import { EditTitlePost } from "../components/uploadPhoto/EditTitlePost"
@@ -13,7 +13,7 @@ import { history } from '../App'
 const ContainEditorPost = ({ children }) =>
     <div className='ContainEditPost ContainerInner'>{children}</div>
 
-const EntityEditorPost = ({ match: { params: { _id } }, myID, entity, status, onSave, updatePost, clearState }) => {
+const EntityEditorPost = ({ match: { params: { _id } }, myID, entity, status, onSave, updatePost, clearState, clearStatus }) => {
 
     const [photos, setPhotos] = useState(entity?.images || []);
     const [titleSend, setTitleSend] = useState(entity?.title || '')
@@ -35,6 +35,7 @@ const EntityEditorPost = ({ match: { params: { _id } }, myID, entity, status, on
         }
         return () => {
             clearState()
+            clearStatus('sentPost')
         }
     }, []);
 
@@ -74,4 +75,5 @@ export const CEntityEditorPost = connect(state => ({
         updatePost: actionAddPostAC,
         onSave: actionFullSentPost,
         clearState: actionRemovePostAC,
+        clearStatus: actionClearPromise
     })(EntityEditorPost)

文件差异内容过多而无法显示
+ 16 - 9
src/redux/saga/index.js