From 96a7e99e57f8c79eead599e6de5d94016f7021e6 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Sun, 2 Feb 2020 12:45:41 -0500 Subject: Removing PostLikeResponse in favor of PostResponse. Consolidating comment and post_sends. --- ui/src/components/community.tsx | 3 +-- ui/src/components/main.tsx | 3 +-- ui/src/components/post.tsx | 7 +++---- ui/src/components/search.tsx | 4 ++-- ui/src/interfaces.ts | 6 +----- 5 files changed, 8 insertions(+), 15 deletions(-) (limited to 'ui') diff --git a/ui/src/components/community.tsx b/ui/src/components/community.tsx index 866b9eec..18767c51 100644 --- a/ui/src/components/community.tsx +++ b/ui/src/components/community.tsx @@ -15,7 +15,6 @@ import { ListingType, GetPostsResponse, PostResponse, - CreatePostLikeResponse, AddModToCommunityResponse, BanFromCommunityResponse, WebSocketJsonResponse, @@ -294,7 +293,7 @@ export class Community extends Component { this.state.posts.unshift(data.post); this.setState(this.state); } else if (res.op == UserOperation.CreatePostLike) { - let data = res.data as CreatePostLikeResponse; + let data = res.data as PostResponse; let found = this.state.posts.find(c => c.id == data.post.id); found.score = data.post.score; diff --git a/ui/src/components/main.tsx b/ui/src/components/main.tsx index 9ff6af44..ec801f90 100644 --- a/ui/src/components/main.tsx +++ b/ui/src/components/main.tsx @@ -14,7 +14,6 @@ import { ListingType, SiteResponse, GetPostsResponse, - CreatePostLikeResponse, PostResponse, Post, GetPostsForm, @@ -622,7 +621,7 @@ export class Main extends Component { this.setState(this.state); } else if (res.op == UserOperation.CreatePostLike) { - let data = res.data as CreatePostLikeResponse; + let data = res.data as PostResponse; let found = this.state.posts.find(c => c.id == data.post.id); found.score = data.post.score; diff --git a/ui/src/components/post.tsx b/ui/src/components/post.tsx index fcf79438..b53d7d4f 100644 --- a/ui/src/components/post.tsx +++ b/ui/src/components/post.tsx @@ -11,7 +11,6 @@ import { CommentForm as CommentFormI, CommentResponse, CommentSortType, - CreatePostLikeResponse, CommunityUser, CommunityResponse, CommentNode as CommentNodeI, @@ -401,8 +400,8 @@ export class Post extends Component { } else if (res.op == UserOperation.CreateComment) { let data = res.data as CommentResponse; - // Necessary since a user might receive a comment reply on another thread - if (data.comment.post_id == this.state.post.id) { + // Necessary since it might be a user reply + if (data.recipient_ids.length == 0) { this.state.comments.unshift(data.comment); this.setState(this.state); } @@ -439,7 +438,7 @@ export class Post extends Component { } this.setState(this.state); } else if (res.op == UserOperation.CreatePostLike) { - let data = res.data as CreatePostLikeResponse; + let data = res.data as PostResponse; this.state.post.score = data.post.score; this.state.post.upvotes = data.post.upvotes; this.state.post.downvotes = data.post.downvotes; diff --git a/ui/src/components/search.tsx b/ui/src/components/search.tsx index 604c2617..f376f609 100644 --- a/ui/src/components/search.tsx +++ b/ui/src/components/search.tsx @@ -12,7 +12,7 @@ import { SearchForm, SearchResponse, SearchType, - CreatePostLikeResponse, + PostResponse, CommentResponse, WebSocketJsonResponse, } from '../interfaces'; @@ -506,7 +506,7 @@ export class Search extends Component { } this.setState(this.state); } else if (res.op == UserOperation.CreatePostLike) { - let data = res.data as CreatePostLikeResponse; + let data = res.data as PostResponse; let found = this.state.searchResponse.posts.find( c => c.id == data.post.id ); diff --git a/ui/src/interfaces.ts b/ui/src/interfaces.ts index 4036f7e6..98cdc763 100644 --- a/ui/src/interfaces.ts +++ b/ui/src/interfaces.ts @@ -664,10 +664,6 @@ export interface CreatePostLikeForm { auth?: string; } -export interface CreatePostLikeResponse { - post: Post; -} - export interface SiteForm { name: string; description?: string; @@ -831,7 +827,7 @@ type ResponseType = | GetFollowedCommunitiesResponse | ListCommunitiesResponse | GetPostsResponse - | CreatePostLikeResponse + | PostResponse | GetRepliesResponse | GetUserMentionsResponse | ListCategoriesResponse -- cgit v1.2.3