From b95d53791ca5e729e8912c75649223560b949e4d Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Thu, 4 Mar 2021 13:51:03 +0700 Subject: [PATCH] fixed node liking --- src/components/profile/ProfileDescription/index.tsx | 4 +++- src/redux/node/sagas.ts | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/profile/ProfileDescription/index.tsx b/src/components/profile/ProfileDescription/index.tsx index f3b43ea1..e083c47a 100644 --- a/src/components/profile/ProfileDescription/index.tsx +++ b/src/components/profile/ProfileDescription/index.tsx @@ -5,6 +5,8 @@ import { connect } from 'react-redux'; import { selectAuthProfile } from '~/redux/auth/selectors'; import { ProfileLoader } from '~/containers/profile/ProfileLoader'; import { Group } from '~/components/containers/Group'; +import markdown from '~/styles/common/markdown.module.scss'; +import classNames from 'classnames'; const mapStateToProps = state => ({ profile: selectAuthProfile(state), @@ -19,7 +21,7 @@ const ProfileDescriptionUnconnected: FC = ({ profile: { user, is_loading
{!!user?.description && ( )} diff --git a/src/redux/node/sagas.ts b/src/redux/node/sagas.ts index 8a629dfe..15cf8909 100644 --- a/src/redux/node/sagas.ts +++ b/src/redux/node/sagas.ts @@ -258,9 +258,9 @@ function* onEditSaga({ id }: ReturnType) { } function* onLikeSaga({ id }: ReturnType) { - try { - const { current }: ReturnType = yield select(selectNode); + const { current }: ReturnType = yield select(selectNode); + try { const count = current.like_count || 0; yield call(updateNodeEverywhere, { @@ -274,6 +274,7 @@ function* onLikeSaga({ id }: ReturnType) { yield call(updateNodeEverywhere, { ...current, is_liked: data.is_liked, + like_count: data.is_liked ? count + 1 : Math.max(count - 1, 0), }); } catch {} }