|
@@ -1,4 +1,4 @@
|
|
-import { actionAddComment, actionAddCommentAC, actionAddLikePost, actionAddLikePostAC, actionAddPostsFeedAC, actionAuthLogin, actionFindComment, actionLogin, actionMyLikePost, actionPending, actionRegister, actionRejected, actionRemoveLikePost, actionRemoveLikePostAC, actionResolved, actionUserData, actionUserPost, actionAddProfileDataAC } from "../actions"
|
|
|
|
|
|
+import { actionAddComment, actionAddCommentAC, actionAddLikePost, actionAddLikePostAC, actionAddPostsFeedAC, actionAuthLogin, actionFindComment, actionLogin, actionMyLikePost, actionPending, actionRegister, actionRejected, actionRemoveLikePost, actionRemoveLikePostAC, actionResolved, actionUserData, actionUserPost, actionAddProfileDataAC, actionSubscribe, actionUpdateFollowers, actionAboutMe } from "../actions"
|
|
import { actionMyFolowisgPosts } from "./post-reducer"
|
|
import { actionMyFolowisgPosts } from "./post-reducer"
|
|
|
|
|
|
export const actionPromise = (name, promise) =>
|
|
export const actionPromise = (name, promise) =>
|
|
@@ -15,10 +15,11 @@ export const actionPromise = (name, promise) =>
|
|
}
|
|
}
|
|
|
|
|
|
export const actionFullLogin = (login, password, remember) =>
|
|
export const actionFullLogin = (login, password, remember) =>
|
|
- async dispatch => {
|
|
|
|
- let token = await dispatch(actionLogin(login, password))
|
|
|
|
|
|
+ async (dispatch) => {
|
|
|
|
+ const token = await dispatch(actionLogin(login, password))
|
|
|
|
+ actionAboutMe()
|
|
if (token) {
|
|
if (token) {
|
|
- dispatch(actionAuthLogin(token, remember))
|
|
|
|
|
|
+ await dispatch(actionAuthLogin(token, remember))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -27,7 +28,7 @@ export const actionFullRegister = (login, password, remember) =>
|
|
await 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) {
|
|
- dispatch(actionAuthLogin(token, remember))
|
|
|
|
|
|
+ await dispatch(actionAuthLogin(token, remember))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -37,7 +38,7 @@ export const actionFullRemoveLikePost = (likeId, postId) =>
|
|
const { likes } = await dispatch(actionMyLikePost(postId))
|
|
const { likes } = await dispatch(actionMyLikePost(postId))
|
|
console.log(likes);
|
|
console.log(likes);
|
|
if (likes) {
|
|
if (likes) {
|
|
- dispatch(actionRemoveLikePostAC(postId, likes))
|
|
|
|
|
|
+ await dispatch(actionRemoveLikePostAC(postId, likes))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -46,7 +47,7 @@ export const actionFullAddLikePost = (postId) =>
|
|
await actionAddLikePost(postId)
|
|
await actionAddLikePost(postId)
|
|
const { likes } = await dispatch(actionMyLikePost(postId))
|
|
const { likes } = await dispatch(actionMyLikePost(postId))
|
|
if (likes) {
|
|
if (likes) {
|
|
- dispatch(actionAddLikePostAC(postId, likes))
|
|
|
|
|
|
+ await dispatch(actionAddLikePostAC(postId, likes))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -54,7 +55,7 @@ export const actionAddPostsFeed = (skip) =>
|
|
async dispatch => {
|
|
async dispatch => {
|
|
let posts = await dispatch(actionMyFolowisgPosts(skip))
|
|
let posts = await dispatch(actionMyFolowisgPosts(skip))
|
|
if (posts) {
|
|
if (posts) {
|
|
- dispatch(actionAddPostsFeedAC(posts))
|
|
|
|
|
|
+ await dispatch(actionAddPostsFeedAC(posts))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -63,7 +64,7 @@ export const actionFullAddComment = (postId, text) =>
|
|
await actionAddComment(postId, text)
|
|
await actionAddComment(postId, text)
|
|
const { comments } = await dispatch(actionFindComment(postId))
|
|
const { comments } = await dispatch(actionFindComment(postId))
|
|
if (comments) {
|
|
if (comments) {
|
|
- dispatch(actionAddCommentAC(postId, comments))
|
|
|
|
|
|
+ await dispatch(actionAddCommentAC(postId, comments))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -72,6 +73,21 @@ export const actionProfilePageData = (id) =>
|
|
const userData = await dispatch(actionUserData(id))
|
|
const userData = await dispatch(actionUserData(id))
|
|
const userPosts = await dispatch(actionUserPost(id))
|
|
const userPosts = await dispatch(actionUserPost(id))
|
|
if (userData, userPosts) {
|
|
if (userData, userPosts) {
|
|
- dispatch(actionAddProfileDataAC(userData, userPosts))
|
|
|
|
|
|
+ await dispatch(actionAddProfileDataAC(userData, userPosts))
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+export const actionFullSubscribe = (userId) =>
|
|
|
|
+ async (dispatch, getState) => {
|
|
|
|
+ const { auth: { payload: { sub: { id } } },
|
|
|
|
+ promise: { dataProfileAuth: { payload: { following } } } } = getState()
|
|
|
|
+ console.log(id, following, userId)
|
|
|
|
+ // actionSubscribe(id, following, userId)
|
|
|
|
+ const followers = await dispatch(actionUpdateFollowers(userId))
|
|
|
|
+ console.log(followers);
|
|
|
|
+ // const userData = await dispatch(actionUserData(id))
|
|
|
|
+ // const userPosts = await dispatch(actionUserPost(id))
|
|
|
|
+ // if (userData, userPosts) {
|
|
|
|
+ // dispatch(actionAddProfileDataAC(userData, userPosts))
|
|
|
|
+ // }
|
|
}
|
|
}
|