Procházet zdrojové kódy

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

makstravm před 2 roky
rodič
revize
fccf8ed63b
3 změnil soubory, kde provedl 23 přidání a 20 odebrání
  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)

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 16 - 9
src/redux/saga/index.js