summaryrefslogtreecommitdiffstats
path: root/ui/src/components/post.tsx
diff options
context:
space:
mode:
authorDessalines <tyhou13@gmx.com>2019-05-19 09:15:08 -0700
committerDessalines <tyhou13@gmx.com>2019-05-19 09:15:08 -0700
commit1b6ddb869ceca51dbd6ea92457738d0f9846796d (patch)
tree9e2b78375daf54fb31108aec7a1a3a7fe1bf860b /ui/src/components/post.tsx
parentd1fee01c6a9675ed24b5d37bd1738d5eb770d511 (diff)
Mark as read if viewing link.
- Fixes #154. #153
Diffstat (limited to 'ui/src/components/post.tsx')
-rw-r--r--ui/src/components/post.tsx26
1 files changed, 24 insertions, 2 deletions
diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx
index 8fa18fbf..3e2e07b3 100644
--- a/ui/src/components/post.tsx
+++ b/ui/src/components/post.tsx
@@ -1,8 +1,8 @@
import { Component, linkEvent } from 'inferno';
import { Subscription } from "rxjs";
import { retryWhen, delay, take } from 'rxjs/operators';
-import { UserOperation, Community, Post as PostI, GetPostResponse, PostResponse, Comment, CommentResponse, CommentSortType, CreatePostLikeResponse, CommunityUser, CommunityResponse, CommentNode as CommentNodeI, BanFromCommunityResponse, BanUserResponse, AddModToCommunityResponse, AddAdminResponse, UserView } from '../interfaces';
-import { WebSocketService } from '../services';
+import { UserOperation, Community, Post as PostI, GetPostResponse, PostResponse, Comment, CommentForm as CommentFormI, CommentResponse, CommentSortType, CreatePostLikeResponse, CommunityUser, CommunityResponse, CommentNode as CommentNodeI, BanFromCommunityResponse, BanUserResponse, AddModToCommunityResponse, AddAdminResponse, UserView } from '../interfaces';
+import { WebSocketService, UserService } from '../services';
import { msgOp, hotRank } from '../utils';
import { PostListing } from './post-listing';
import { Sidebar } from './sidebar';
@@ -71,6 +71,27 @@ export class Post extends Component<any, PostState> {
elmnt.scrollIntoView();
elmnt.classList.add("mark-two");
this.state.scrolled = true;
+ this.markScrolledAsRead(this.state.scrolled_comment_id);
+ }
+ }
+
+ markScrolledAsRead(commentId: number) {
+ let found = this.state.comments.find(c => c.id == commentId);
+ let parent = this.state.comments.find(c => found.parent_id == c.id);
+ let parent_user_id = parent ? parent.creator_id : this.state.post.creator_id;
+
+ if (UserService.Instance.user && UserService.Instance.user.id == parent_user_id) {
+
+ let form: CommentFormI = {
+ content: found.content,
+ edit_id: found.id,
+ creator_id: found.creator_id,
+ post_id: found.post_id,
+ parent_id: found.parent_id,
+ read: true,
+ auth: null
+ };
+ WebSocketService.Instance.editComment(form);
}
}
@@ -248,6 +269,7 @@ export class Post extends Component<any, PostState> {
found.upvotes = res.comment.upvotes;
found.downvotes = res.comment.downvotes;
found.score = res.comment.score;
+ found.read = res.comment.read;
this.setState(this.state);
} else if (op == UserOperation.SaveComment) {