BanFromCommunityResponse,
BanPersonResponse,
BlockPersonResponse,
- CommentNode as CommentNodeI,
CommentReportResponse,
CommentResponse,
CommentSortType,
GetPost,
GetPostResponse,
GetSiteResponse,
- ListingType,
PostReportResponse,
PostResponse,
PostView,
PurgeItemResponse,
Search,
SearchResponse,
- SearchType,
- SortType,
UserOperation,
wsJsonToRes,
wsUserOp,
} from "lemmy-js-client";
import { Subscription } from "rxjs";
import { i18n } from "../../i18next";
-import { CommentViewType, InitialFetchRequest } from "../../interfaces";
+import {
+ CommentNodeI,
+ CommentViewType,
+ InitialFetchRequest,
+} from "../../interfaces";
import { UserService, WebSocketService } from "../../services";
import {
buildCommentsTree,
postId: getIdFromProps(this.props),
commentId: getCommentIdFromProps(this.props),
commentTree: [],
- commentSort: CommentSortType[CommentSortType.Hot],
+ commentSort: "Hot",
commentViewType: CommentViewType.Tree,
scrolled: false,
loading: true,
parent_id: this.state.commentId,
max_depth: commentTreeMaxDepth,
sort: this.state.commentSort,
- type_: ListingType.All,
+ type_: "All",
saved_only: false,
auth,
};
if (q) {
let form: Search = {
q,
- type_: SearchType.Url,
- sort: SortType.TopAll,
- listing_type: ListingType.All,
+ type_: "Url",
+ sort: "TopAll",
+ listing_type: "All",
page: 1,
limit: trendingFetchLimit,
auth: myAuth(false),
let commentsForm: GetComments = {
max_depth: commentTreeMaxDepth,
- sort: CommentSortType.Hot,
- type_: ListingType.All,
+ sort: "Hot",
+ type_: "All",
saved_only: false,
auth,
};
<div className="btn-group btn-group-toggle flex-wrap mr-3 mb-2">
<label
className={`btn btn-outline-secondary pointer ${
- CommentSortType[this.state.commentSort] === CommentSortType.Hot &&
- "active"
+ this.state.commentSort === "Hot" && "active"
}`}
>
{i18n.t("hot")}
<input
type="radio"
- value={CommentSortType.Hot}
- checked={this.state.commentSort === CommentSortType.Hot}
+ value={"Hot"}
+ checked={this.state.commentSort === "Hot"}
onChange={linkEvent(this, this.handleCommentSortChange)}
/>
</label>
<label
className={`btn btn-outline-secondary pointer ${
- CommentSortType[this.state.commentSort] === CommentSortType.Top &&
- "active"
+ this.state.commentSort === "Top" && "active"
}`}
>
{i18n.t("top")}
<input
type="radio"
- value={CommentSortType.Top}
- checked={this.state.commentSort === CommentSortType.Top}
+ value={"Top"}
+ checked={this.state.commentSort === "Top"}
onChange={linkEvent(this, this.handleCommentSortChange)}
/>
</label>
<label
className={`btn btn-outline-secondary pointer ${
- CommentSortType[this.state.commentSort] === CommentSortType.New &&
- "active"
+ this.state.commentSort === "New" && "active"
}`}
>
{i18n.t("new")}
<input
type="radio"
- value={CommentSortType.New}
- checked={this.state.commentSort === CommentSortType.New}
+ value={"New"}
+ checked={this.state.commentSort === "New"}
onChange={linkEvent(this, this.handleCommentSortChange)}
/>
</label>
<label
className={`btn btn-outline-secondary pointer ${
- CommentSortType[this.state.commentSort] === CommentSortType.Old &&
- "active"
+ this.state.commentSort === "Old" && "active"
}`}
>
{i18n.t("old")}
<input
type="radio"
- value={CommentSortType.Old}
- checked={this.state.commentSort === CommentSortType.Old}
+ value={"Old"}
+ checked={this.state.commentSort === "Old"}
onChange={linkEvent(this, this.handleCommentSortChange)}
/>
</label>
handleCommentSortChange(i: Post, event: any) {
i.setState({
- commentSort: CommentSortType[event.target.value],
+ commentSort: event.target.value as CommentSortType,
commentViewType: CommentViewType.Tree,
commentsRes: undefined,
postRes: undefined,
if (comments) {
i.setState({
commentViewType: Number(event.target.value),
- commentSort: CommentSortType.New,
+ commentSort: "New",
commentTree: buildCommentsTree(comments, !!i.state.commentId),
});
}
data.recipient_ids.length == 0 &&
!creatorBlocked &&
postRes &&
+ data.comment_view.post.id == postRes.post_view.post.id &&
commentsRes
) {
commentsRes.comments.unshift(data.comment_view);
} else if (op == UserOperation.Search) {
let data = wsJsonToRes<SearchResponse>(msg);
let xPosts = data.posts.filter(
- p => p.post.id != Number(this.props.match.params.id)
+ p => p.post.ap_id != this.state.postRes?.post_view.post.ap_id
);
this.setState({ crossPosts: xPosts.length > 0 ? xPosts : undefined });
} else if (op == UserOperation.LeaveAdmin) {