UserDetailsResponse,
UserView,
WebSocketJsonResponse,
- UserDetailsView,
CommentResponse,
BanUserResponse,
PostResponse,
-} from '../interfaces';
+} from 'lemmy-js-client';
+import { UserDetailsView } from '../interfaces';
import {
wsJsonToRes,
toast,
user_id?: number;
page: number;
limit: number;
- sort: string;
+ sort: SortType;
enableDownvotes: boolean;
enableNsfw: boolean;
view: UserDetailsView;
componentDidMount() {
this.fetchUserData();
+ setupTippy();
}
componentDidUpdate(lastProps: UserDetailsProps) {
break;
}
}
- setupTippy();
}
fetchUserData() {
];
// Sort it
- if (SortType[this.props.sort] === SortType.New) {
+ if (this.props.sort === SortType.New) {
combined.sort((a, b) => b.data.published.localeCompare(a.data.published));
} else {
combined.sort((a, b) => b.data.score - a.data.score);
return (
<div>
{combined.map(i => (
- <div>
- {i.type === 'posts' ? (
- <PostListing
- post={i.data as Post}
- admins={this.props.admins}
- showCommunity
- enableDownvotes={this.props.enableDownvotes}
- enableNsfw={this.props.enableNsfw}
- />
- ) : (
- <CommentNodes
- nodes={[{ comment: i.data as Comment }]}
- admins={this.props.admins}
- noIndent
- showContext
- enableDownvotes={this.props.enableDownvotes}
- />
- )}
- </div>
+ <>
+ <div>
+ {i.type === 'posts' ? (
+ <PostListing
+ key={(i.data as Post).id}
+ post={i.data as Post}
+ admins={this.props.admins}
+ showCommunity
+ enableDownvotes={this.props.enableDownvotes}
+ enableNsfw={this.props.enableNsfw}
+ />
+ ) : (
+ <CommentNodes
+ key={(i.data as Comment).id}
+ nodes={[{ comment: i.data as Comment }]}
+ admins={this.props.admins}
+ noBorder
+ noIndent
+ showCommunity
+ showContext
+ enableDownvotes={this.props.enableDownvotes}
+ />
+ )}
+ </div>
+ <hr class="my-3" />
+ </>
))}
</div>
);
nodes={commentsToFlatNodes(this.state.comments)}
admins={this.props.admins}
noIndent
+ showCommunity
showContext
enableDownvotes={this.props.enableDownvotes}
/>
return (
<div>
{this.state.posts.map(post => (
- <PostListing
- post={post}
- admins={this.props.admins}
- showCommunity
- enableDownvotes={this.props.enableDownvotes}
- enableNsfw={this.props.enableNsfw}
- />
+ <>
+ <PostListing
+ post={post}
+ admins={this.props.admins}
+ showCommunity
+ enableDownvotes={this.props.enableDownvotes}
+ enableNsfw={this.props.enableNsfw}
+ />
+ <hr class="my-3" />
+ </>
))}
</div>
);
<div class="my-2">
{this.props.page > 1 && (
<button
- class="btn btn-sm btn-secondary mr-1"
+ class="btn btn-secondary mr-1"
onClick={linkEvent(this, this.prevPage)}
>
{i18n.t('prev')}
)}
{this.state.comments.length + this.state.posts.length > 0 && (
<button
- class="btn btn-sm btn-secondary"
+ class="btn btn-secondary"
onClick={linkEvent(this, this.nextPage)}
>
{i18n.t('next')}
this.setState({
comments: this.state.comments,
});
- } else if (res.op == UserOperation.EditComment) {
+ } else if (
+ res.op == UserOperation.EditComment ||
+ res.op == UserOperation.DeleteComment ||
+ res.op == UserOperation.RemoveComment
+ ) {
const data = res.data as CommentResponse;
editCommentRes(data, this.state.comments);
this.setState({