forked from nutomic/lemmy
Fixing new comments and posts voting issue. Fixes #422
This commit is contained in:
parent
66adf67661
commit
2394993dd4
4 changed files with 23 additions and 14 deletions
12
ui/src/components/comment-node.tsx
vendored
12
ui/src/components/comment-node.tsx
vendored
|
@ -91,6 +91,18 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
|
||||||
this.handleCommentDisLike = this.handleCommentDisLike.bind(this);
|
this.handleCommentDisLike = this.handleCommentDisLike.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps: CommentNodeProps) {
|
||||||
|
if (
|
||||||
|
prevProps.node.comment.my_vote !== this.props.node.comment.my_vote ||
|
||||||
|
this.state.score !== this.props.node.comment.score
|
||||||
|
) {
|
||||||
|
this.setState({
|
||||||
|
my_vote: this.props.node.comment.my_vote,
|
||||||
|
score: this.props.node.comment.score,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let node = this.props.node;
|
let node = this.props.node;
|
||||||
return (
|
return (
|
||||||
|
|
7
ui/src/components/community.tsx
vendored
7
ui/src/components/community.tsx
vendored
|
@ -147,7 +147,7 @@ export class Community extends Component<any, State> {
|
||||||
)}
|
)}
|
||||||
</h5>
|
</h5>
|
||||||
{this.selects()}
|
{this.selects()}
|
||||||
{this.state.posts && <PostListings posts={this.state.posts} />}
|
<PostListings posts={this.state.posts} />
|
||||||
{this.paginator()}
|
{this.paginator()}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-md-4">
|
<div class="col-12 col-md-4">
|
||||||
|
@ -280,11 +280,6 @@ export class Community extends Component<any, State> {
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
} else if (op == UserOperation.GetPosts) {
|
} else if (op == UserOperation.GetPosts) {
|
||||||
let res: GetPostsResponse = msg;
|
let res: GetPostsResponse = msg;
|
||||||
|
|
||||||
// This is needed to refresh the view
|
|
||||||
this.state.posts = undefined;
|
|
||||||
this.setState(this.state);
|
|
||||||
|
|
||||||
this.state.posts = res.posts;
|
this.state.posts = res.posts;
|
||||||
this.state.loading = false;
|
this.state.loading = false;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
|
7
ui/src/components/main.tsx
vendored
7
ui/src/components/main.tsx
vendored
|
@ -422,9 +422,7 @@ export class Main extends Component<any, MainState> {
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<div>
|
||||||
{this.selects()}
|
{this.selects()}
|
||||||
{this.state.posts && (
|
|
||||||
<PostListings posts={this.state.posts} showCommunity />
|
<PostListings posts={this.state.posts} showCommunity />
|
||||||
)}
|
|
||||||
{this.paginator()}
|
{this.paginator()}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
@ -598,11 +596,6 @@ export class Main extends Component<any, MainState> {
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
} else if (op == UserOperation.GetPosts) {
|
} else if (op == UserOperation.GetPosts) {
|
||||||
let res: GetPostsResponse = msg;
|
let res: GetPostsResponse = msg;
|
||||||
|
|
||||||
// This is needed to refresh the view
|
|
||||||
this.state.posts = undefined;
|
|
||||||
this.setState(this.state);
|
|
||||||
|
|
||||||
this.state.posts = res.posts;
|
this.state.posts = res.posts;
|
||||||
this.state.loading = false;
|
this.state.loading = false;
|
||||||
this.setState(this.state);
|
this.setState(this.state);
|
||||||
|
|
9
ui/src/components/post-listing.tsx
vendored
9
ui/src/components/post-listing.tsx
vendored
|
@ -84,6 +84,15 @@ export class PostListing extends Component<PostListingProps, PostListingState> {
|
||||||
this.handleEditCancel = this.handleEditCancel.bind(this);
|
this.handleEditCancel = this.handleEditCancel.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps: PostListingProps) {
|
||||||
|
if (prevProps.post.my_vote !== this.props.post.my_vote) {
|
||||||
|
this.setState({
|
||||||
|
my_vote: this.props.post.my_vote,
|
||||||
|
score: this.props.post.score,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
Loading…
Reference in a new issue