|
@@ -1,5 +1,5 @@
|
|
-import { actionAddComment, actionAddCommentAC, actionAddLikePost, actionAddLikePostAC, actionAddPostsFeedAC, actionAuthLogin, actionFindComment, actionLogin, actionMyLikePost, actionPending, actionRegister, actionRejected, actionRemoveLikePost, actionRemoveLikePostAC, actionResolved, actionSubscribe, actionUpdateFollowers, actionAboutMe, actionProfilePagePost, actionProfilePageDataAC, actionProfilePageData, actionUnSubscribe, actionUpdateFollowingAC } from "../actions"
|
|
|
|
-import { actionMyFolowisgPosts } from "./post-reducer"
|
|
|
|
|
|
+import { actionAddComment, actionAddCommentAC, actionAddLikePost, actionAddLikePostAC, actionAuthLogin, actionFindComment, actionLogin, actionMyLikePost, actionPending, actionRegister, actionRejected, actionRemoveLikePost, actionRemoveLikePostAC, actionResolved, actionSubscribe, actionUpdateFollowers, actionAboutMe, actionProfilePagePost, actionProfilePageDataAC, actionProfilePageData, actionUnSubscribe, actionUpdateFollowingAC, actionRenderPostsAC, actionRenderPostsFeedAC } from "../actions"
|
|
|
|
+import { actionMyFolowingPosts } from "./postsFeed-reducer"
|
|
|
|
|
|
export const actionPromise = (name, promise) =>
|
|
export const actionPromise = (name, promise) =>
|
|
async dispatch => {
|
|
async dispatch => {
|
|
@@ -25,7 +25,7 @@ export const actionFullLogin = (login, password, remember) =>
|
|
|
|
|
|
export const actionFullRegister = (login, password, remember) =>
|
|
export const actionFullRegister = (login, password, remember) =>
|
|
async dispatch => {
|
|
async dispatch => {
|
|
- await dispatch(actionRegister(login, password))
|
|
|
|
|
|
+ await actionRegister(login, password)
|
|
let token = await dispatch(actionLogin(login, password))
|
|
let token = await dispatch(actionLogin(login, password))
|
|
if (token) {
|
|
if (token) {
|
|
await dispatch(actionAuthLogin(token, remember))
|
|
await dispatch(actionAuthLogin(token, remember))
|
|
@@ -34,7 +34,7 @@ export const actionFullRegister = (login, password, remember) =>
|
|
|
|
|
|
export const actionFullRemoveLikePost = (likeId, postId) =>
|
|
export const actionFullRemoveLikePost = (likeId, postId) =>
|
|
async dispatch => {
|
|
async dispatch => {
|
|
- await dispatch(actionRemoveLikePost(likeId))
|
|
|
|
|
|
+ await actionRemoveLikePost(likeId)
|
|
const { likes } = await dispatch(actionMyLikePost(postId))
|
|
const { likes } = await dispatch(actionMyLikePost(postId))
|
|
if (likes) {
|
|
if (likes) {
|
|
await dispatch(actionRemoveLikePostAC(postId, likes))
|
|
await dispatch(actionRemoveLikePostAC(postId, likes))
|
|
@@ -43,18 +43,18 @@ export const actionFullRemoveLikePost = (likeId, postId) =>
|
|
|
|
|
|
export const actionFullAddLikePost = (postId) =>
|
|
export const actionFullAddLikePost = (postId) =>
|
|
async dispatch => {
|
|
async dispatch => {
|
|
- await dispatch(actionAddLikePost(postId))
|
|
|
|
|
|
+ await actionAddLikePost(postId)
|
|
const { likes } = await dispatch(actionMyLikePost(postId))
|
|
const { likes } = await dispatch(actionMyLikePost(postId))
|
|
if (likes) {
|
|
if (likes) {
|
|
await dispatch(actionAddLikePostAC(postId, likes))
|
|
await dispatch(actionAddLikePostAC(postId, likes))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-export const actionAddPostsFeed = (skip) =>
|
|
|
|
|
|
+export const actionRenderPostsFeed = (skip) =>
|
|
async dispatch => {
|
|
async dispatch => {
|
|
- let posts = await dispatch(actionMyFolowisgPosts(skip))
|
|
|
|
|
|
+ let posts = await dispatch(actionMyFolowingPosts(skip))
|
|
if (posts) {
|
|
if (posts) {
|
|
- await dispatch(actionAddPostsFeedAC(posts))
|
|
|
|
|
|
+ await dispatch(actionRenderPostsFeedAC(posts))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -72,8 +72,7 @@ export const actionFullProfilePageData = (id) =>
|
|
const userData = await dispatch(actionProfilePageData(id))
|
|
const userData = await dispatch(actionProfilePageData(id))
|
|
const userPosts = await dispatch(actionProfilePagePost(id))
|
|
const userPosts = await dispatch(actionProfilePagePost(id))
|
|
if (userData && userPosts) {
|
|
if (userData && userPosts) {
|
|
- await dispatch(actionProfilePageDataAC(userData))
|
|
|
|
- await dispatch(actionAddPostsFeedAC (userPosts))
|
|
|
|
|
|
+ await dispatch(actionProfilePageDataAC(userData, userPosts))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -81,8 +80,10 @@ export const actionFullSubscribe = (userId) =>
|
|
async (dispatch, getState) => {
|
|
async (dispatch, getState) => {
|
|
const { auth: { payload: { sub: { id } } },
|
|
const { auth: { payload: { sub: { id } } },
|
|
promise: { aboutMe: { payload: { following } } } } = getState()
|
|
promise: { aboutMe: { payload: { following } } } } = getState()
|
|
- await dispatch(actionSubscribe(id, following, userId))
|
|
|
|
|
|
+ await actionSubscribe(id, following, userId)
|
|
|
|
+ await dispatch(actionAboutMe())
|
|
const { followers } = await dispatch(actionUpdateFollowers(userId))
|
|
const { followers } = await dispatch(actionUpdateFollowers(userId))
|
|
|
|
+
|
|
if (followers) {
|
|
if (followers) {
|
|
await dispatch(actionUpdateFollowingAC(followers))
|
|
await dispatch(actionUpdateFollowingAC(followers))
|
|
}
|
|
}
|
|
@@ -93,8 +94,10 @@ export const actionFullUnSubscribe = (userId) =>
|
|
const { auth: { payload: { sub: { id } } },
|
|
const { auth: { payload: { sub: { id } } },
|
|
promise: { aboutMe: { payload: { following } } } } = getState()
|
|
promise: { aboutMe: { payload: { following } } } } = getState()
|
|
const newArrFollowing = [...following].filter(f => f._id !== userId)
|
|
const newArrFollowing = [...following].filter(f => f._id !== userId)
|
|
- await dispatch(actionUnSubscribe(id, newArrFollowing))
|
|
|
|
|
|
+ await actionUnSubscribe(id, newArrFollowing)
|
|
|
|
+ await dispatch(actionAboutMe())
|
|
const { followers } = await dispatch(actionUpdateFollowers(userId))
|
|
const { followers } = await dispatch(actionUpdateFollowers(userId))
|
|
|
|
+
|
|
if (followers) {
|
|
if (followers) {
|
|
await dispatch(actionUpdateFollowingAC(followers))
|
|
await dispatch(actionUpdateFollowingAC(followers))
|
|
}
|
|
}
|