|
@@ -51,7 +51,8 @@ import {
|
|
actionClearFeedPosts,
|
|
actionClearFeedPosts,
|
|
actionFeedType,
|
|
actionFeedType,
|
|
actionClearFeedPostsType,
|
|
actionClearFeedPostsType,
|
|
- actionAddCommentPostFeedTape
|
|
|
|
|
|
+ actionAddCommentPostFeedType,
|
|
|
|
+ actionAddLikePostFeedType
|
|
} from '../reducers/feedReducer'
|
|
} from '../reducers/feedReducer'
|
|
import { actionProfilePageDataTypeUser,actionCountPostsType } from '../reducers/userProfileReducer'
|
|
import { actionProfilePageDataTypeUser,actionCountPostsType } from '../reducers/userProfileReducer'
|
|
import { actionRemoveDataAboutMe,actionUpdateAvatarType } from '../reducers/myProfileReducer'
|
|
import { actionRemoveDataAboutMe,actionUpdateAvatarType } from '../reducers/myProfileReducer'
|
|
@@ -86,6 +87,7 @@ function* loginWorker({login, password}){ //обработчик экшона FU
|
|
if (token) {
|
|
if (token) {
|
|
yield put(actionAuthLogin(token));
|
|
yield put(actionAuthLogin(token));
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
export function* loginWatcher() {
|
|
export function* loginWatcher() {
|
|
yield takeEvery("FULL_LOGIN", loginWorker)
|
|
yield takeEvery("FULL_LOGIN", loginWorker)
|
|
@@ -306,7 +308,7 @@ function* addCommentFeedWorker({ postId, text }) {
|
|
const { comments } = yield call(promiseWorker,
|
|
const { comments } = yield call(promiseWorker,
|
|
actionGetCommentsOnePost(postId))
|
|
actionGetCommentsOnePost(postId))
|
|
if (comments)
|
|
if (comments)
|
|
- yield put (actionAddCommentPostFeedTape(postId,comments))
|
|
|
|
|
|
+ yield put (actionAddCommentPostFeedType(postId,comments))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
export function* addCommentFeedWatcher(){
|
|
export function* addCommentFeedWatcher(){
|
|
@@ -331,8 +333,10 @@ export const actionChangeLike = (likeId, postId) =>
|
|
({
|
|
({
|
|
type:"CHANGE_LIKE_POST", likeId,postId
|
|
type:"CHANGE_LIKE_POST", likeId,postId
|
|
})
|
|
})
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
-function* changeLikePostWorker({ likeId, postId }) {
|
|
|
|
|
|
+function* changeLikeWorker({ likeId, postId }) {
|
|
console.log('likeId', likeId)
|
|
console.log('likeId', likeId)
|
|
console.log('postId', postId)
|
|
console.log('postId', postId)
|
|
|
|
|
|
@@ -340,22 +344,44 @@ function* changeLikePostWorker({ likeId, postId }) {
|
|
likeId ? actionDeleteLike(likeId, postId) : actionAddLike(postId)
|
|
likeId ? actionDeleteLike(likeId, postId) : actionAddLike(postId)
|
|
|
|
|
|
yield call(promiseWorker, changeOneLike())
|
|
yield call(promiseWorker, changeOneLike())
|
|
- const { likes } = yield call(promiseWorker, actionFindLikes(postId))
|
|
|
|
- console.log('likes in worker', likes)
|
|
|
|
|
|
+ return yield call(promiseWorker, actionFindLikes(postId))
|
|
|
|
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function* changeLikePostWorker({ likeId, postId }) {
|
|
|
|
+
|
|
|
|
+ const { likes } = yield call(changeLikeWorker, {likeId, postId})
|
|
if (likes) {
|
|
if (likes) {
|
|
|
|
|
|
- yield call(promiseWorker, actionOnePost(postId))
|
|
|
|
|
|
+ // yield call(promiseWorker, actionOnePost(postId))
|
|
yield put(actionChangeLikeType(likes))
|
|
yield put(actionChangeLikeType(likes))
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+function* changeLikePostFeedWorker({ likeId, postId }) {
|
|
|
|
+ const { likes } = yield call(changeLikeWorker, {likeId, postId})
|
|
|
|
+ if (likes) {
|
|
|
|
+
|
|
|
|
+ // yield call(promiseWorker, actionOnePost(postId))
|
|
|
|
+ yield put(actionAddLikePostFeedType(likes))
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
|
|
|
|
|
|
export function* changeLikePostWatcher() {
|
|
export function* changeLikePostWatcher() {
|
|
yield takeLeading("CHANGE_LIKE_POST", changeLikePostWorker)
|
|
yield takeLeading("CHANGE_LIKE_POST", changeLikePostWorker)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+//change like in post feed
|
|
|
|
+export const actionChangeFeedLike = (likeId, postId) =>
|
|
|
|
+({
|
|
|
|
+ type:"CHANGE_LIKE_POST_FEED", likeId,postId
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+export function* changeLikePostFeedWatcher() {
|
|
|
|
+ yield takeLeading("CHANGE_LIKE_POST_FEED", changeLikePostFeedWorker)
|
|
|
|
+}
|
|
|
|
+
|
|
// create and edit post
|
|
// create and edit post
|
|
|
|
|
|
function* editPostWorker({state }) {
|
|
function* editPostWorker({state }) {
|
|
@@ -480,10 +506,14 @@ function* clearAllDataWorker() {
|
|
const logOut = yield put (actionAuthLogout())
|
|
const logOut = yield put (actionAuthLogout())
|
|
if (logOut) {
|
|
if (logOut) {
|
|
history.push('/input')
|
|
history.push('/input')
|
|
- yield put(actionClearDataUserType())
|
|
|
|
- yield put(actionClearFeedPostsType())
|
|
|
|
- yield put(actionClearAboutMeType())
|
|
|
|
- yield put(actionAllClearPromiseType())
|
|
|
|
|
|
+ yield all([
|
|
|
|
+
|
|
|
|
+ put(actionClearDataUserType()),
|
|
|
|
+ put(actionClearFeedPostsType()),
|
|
|
|
+ put(actionClearAboutMeType()),
|
|
|
|
+ put(actionAllClearPromiseType())
|
|
|
|
+ ])
|
|
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|