1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

fixed boris flickering on load

This commit is contained in:
Fedor Katurov 2019-11-15 12:03:57 +07:00
parent 5b987a5546
commit f23b9166e1
3 changed files with 33 additions and 22 deletions

View file

@ -1,20 +1,20 @@
import React, { FC, useEffect } from 'react';
import { RouteComponentProps } from 'react-router';
import * as NODE_ACTIONS from '~/redux/node/actions';
import { selectNode } from '~/redux/node/selectors';
import { selectUser } from '~/redux/auth/selectors';
import { connect } from 'react-redux';
import { NodeComments } from '~/components/node/NodeComments';
import styles from './styles.scss';
import { CommentForm } from '~/components/node/CommentForm';
import { Group } from '~/components/containers/Group';
import boris from '~/sprites/boris_robot.svg';
import { NodeNoComments } from '~/components/node/NodeNoComments';
import { getRandomPhrase } from '~/constants/phrases';
import React, { FC, useEffect } from "react";
import { RouteComponentProps } from "react-router";
import * as NODE_ACTIONS from "~/redux/node/actions";
import { selectNode } from "~/redux/node/selectors";
import { selectUser } from "~/redux/auth/selectors";
import { connect } from "react-redux";
import { NodeComments } from "~/components/node/NodeComments";
import styles from "./styles.scss";
import { CommentForm } from "~/components/node/CommentForm";
import { Group } from "~/components/containers/Group";
import boris from "~/sprites/boris_robot.svg";
import { NodeNoComments } from "~/components/node/NodeNoComments";
import { getRandomPhrase } from "~/constants/phrases";
const mapStateToProps = state => ({
node: selectNode(state),
user: selectUser(state),
user: selectUser(state)
});
const mapDispatchToProps = {
@ -23,7 +23,7 @@ const mapDispatchToProps = {
nodeSetCoverImage: NODE_ACTIONS.nodeSetCoverImage,
nodeEdit: NODE_ACTIONS.nodeEdit,
nodeLike: NODE_ACTIONS.nodeLike,
nodeStar: NODE_ACTIONS.nodeStar,
nodeStar: NODE_ACTIONS.nodeStar
};
type IProps = ReturnType<typeof mapStateToProps> &
@ -33,15 +33,21 @@ type IProps = ReturnType<typeof mapStateToProps> &
const id = 696;
const BorisLayoutUnconnected: FC<IProps> = ({
node: { is_loading, is_loading_comments, comments = [], current: node, related },
node: {
is_loading,
is_loading_comments,
comments = [],
current: node,
related
},
user: { is_user },
nodeLoadNode,
nodeLoadNode
}) => {
const title = getRandomPhrase('BORIS_TITLE');
const title = getRandomPhrase("BORIS_TITLE");
useEffect(() => {
if (is_loading) return;
nodeLoadNode(id, 'DESC');
nodeLoadNode(id, "DESC");
}, [nodeLoadNode, id]);
return (
@ -81,7 +87,7 @@ const BorisLayoutUnconnected: FC<IProps> = ({
<Group className={styles.content}>
{is_user && <CommentForm id={0} />}
{is_loading_comments ? (
{is_loading_comments && !comments.length ? (
<NodeNoComments is_loading />
) : (
<NodeComments comments={comments} />