mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
fixed node liking
This commit is contained in:
parent
d4c2e7ee09
commit
b95d53791c
2 changed files with 6 additions and 3 deletions
|
@ -5,6 +5,8 @@ import { connect } from 'react-redux';
|
||||||
import { selectAuthProfile } from '~/redux/auth/selectors';
|
import { selectAuthProfile } from '~/redux/auth/selectors';
|
||||||
import { ProfileLoader } from '~/containers/profile/ProfileLoader';
|
import { ProfileLoader } from '~/containers/profile/ProfileLoader';
|
||||||
import { Group } from '~/components/containers/Group';
|
import { Group } from '~/components/containers/Group';
|
||||||
|
import markdown from '~/styles/common/markdown.module.scss';
|
||||||
|
import classNames from 'classnames';
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
profile: selectAuthProfile(state),
|
profile: selectAuthProfile(state),
|
||||||
|
@ -19,7 +21,7 @@ const ProfileDescriptionUnconnected: FC<IProps> = ({ profile: { user, is_loading
|
||||||
<div className={styles.wrap}>
|
<div className={styles.wrap}>
|
||||||
{!!user?.description && (
|
{!!user?.description && (
|
||||||
<Group
|
<Group
|
||||||
className={styles.content}
|
className={classNames(styles.content, markdown.wrapper)}
|
||||||
dangerouslySetInnerHTML={{ __html: formatText(user.description) }}
|
dangerouslySetInnerHTML={{ __html: formatText(user.description) }}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
|
@ -258,9 +258,9 @@ function* onEditSaga({ id }: ReturnType<typeof nodeEdit>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function* onLikeSaga({ id }: ReturnType<typeof nodeLike>) {
|
function* onLikeSaga({ id }: ReturnType<typeof nodeLike>) {
|
||||||
try {
|
const { current }: ReturnType<typeof selectNode> = yield select(selectNode);
|
||||||
const { current }: ReturnType<typeof selectNode> = yield select(selectNode);
|
|
||||||
|
|
||||||
|
try {
|
||||||
const count = current.like_count || 0;
|
const count = current.like_count || 0;
|
||||||
|
|
||||||
yield call(updateNodeEverywhere, {
|
yield call(updateNodeEverywhere, {
|
||||||
|
@ -274,6 +274,7 @@ function* onLikeSaga({ id }: ReturnType<typeof nodeLike>) {
|
||||||
yield call(updateNodeEverywhere, {
|
yield call(updateNodeEverywhere, {
|
||||||
...current,
|
...current,
|
||||||
is_liked: data.is_liked,
|
is_liked: data.is_liked,
|
||||||
|
like_count: data.is_liked ? count + 1 : Math.max(count - 1, 0),
|
||||||
});
|
});
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue