summaryrefslogtreecommitdiffstats
path: root/ui/src/components/user.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2020-01-20 18:39:45 -0500
committerDessalines <tyhou13@gmx.com>2020-01-20 18:39:45 -0500
commita964b4ce21cc19eb42ae4da1a1aef8bfc0a1df5c (patch)
treee1143d93855032c86090e8d153e55f7e778a7a17 /ui/src/components/user.tsx
parent86871d17ac5d6aa14ef8515bd5569c85e68a65b6 (diff)
Allow comment/post upvoting from other pages.
- Fixes #355 - Votes now coming back for posts and comments on search page.
Diffstat (limited to 'ui/src/components/user.tsx')
-rw-r--r--ui/src/components/user.tsx17
1 files changed, 10 insertions, 7 deletions
diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx
index c95b18bb..206fb8ff 100644
--- a/ui/src/components/user.tsx
+++ b/ui/src/components/user.tsx
@@ -18,6 +18,7 @@ import {
BanUserResponse,
AddAdminResponse,
DeleteAccountForm,
+ CreatePostLikeResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import {
@@ -307,7 +308,6 @@ export class User extends Component<any, UserState> {
post={i.data as Post}
admins={this.state.admins}
showCommunity
- viewOnly
/>
) : (
<CommentNodes
@@ -340,12 +340,7 @@ export class User extends Component<any, UserState> {
return (
<div>
{this.state.posts.map(post => (
- <PostListing
- post={post}
- admins={this.state.admins}
- showCommunity
- viewOnly
- />
+ <PostListing post={post} admins={this.state.admins} showCommunity />
))}
</div>
);
@@ -1043,6 +1038,14 @@ export class User extends Component<any, UserState> {
found.downvotes = res.comment.downvotes;
if (res.comment.my_vote !== null) found.my_vote = res.comment.my_vote;
this.setState(this.state);
+ } else if (op == UserOperation.CreatePostLike) {
+ let res: CreatePostLikeResponse = msg;
+ let found = this.state.posts.find(c => c.id == res.post.id);
+ found.my_vote = res.post.my_vote;
+ found.score = res.post.score;
+ found.upvotes = res.post.upvotes;
+ found.downvotes = res.post.downvotes;
+ this.setState(this.state);
} else if (op == UserOperation.BanUser) {
let res: BanUserResponse = msg;
this.state.comments