|
|
|
@ -1,7 +1,7 @@
|
|
|
|
|
import { Component, linkEvent } from 'inferno';
|
|
|
|
|
import { WebSocketService, UserService } from '../services';
|
|
|
|
|
import { Subscription } from 'rxjs';
|
|
|
|
|
import { retryWhen, delay, take, last } from 'rxjs/operators';
|
|
|
|
|
import { retryWhen, delay, take } from 'rxjs/operators';
|
|
|
|
|
import { i18n } from '../i18next';
|
|
|
|
|
import {
|
|
|
|
|
UserOperation,
|
|
|
|
@ -16,7 +16,6 @@ import {
|
|
|
|
|
CommentResponse,
|
|
|
|
|
BanUserResponse,
|
|
|
|
|
PostResponse,
|
|
|
|
|
AddAdminResponse,
|
|
|
|
|
} from '../interfaces';
|
|
|
|
|
import {
|
|
|
|
|
wsJsonToRes,
|
|
|
|
@ -41,6 +40,7 @@ interface UserDetailsProps {
|
|
|
|
|
enableNsfw: boolean;
|
|
|
|
|
view: UserDetailsView;
|
|
|
|
|
onPageChange(page: number): number | any;
|
|
|
|
|
admins: Array<UserView>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface UserDetailsState {
|
|
|
|
@ -49,7 +49,6 @@ interface UserDetailsState {
|
|
|
|
|
comments: Array<Comment>;
|
|
|
|
|
posts: Array<Post>;
|
|
|
|
|
saved?: Array<Post>;
|
|
|
|
|
admins: Array<UserView>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
|
|
|
@ -63,7 +62,6 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
|
|
|
|
comments: [],
|
|
|
|
|
posts: [],
|
|
|
|
|
saved: [],
|
|
|
|
|
admins: [],
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
this.subscription = WebSocketService.Instance.subject
|
|
|
|
@ -152,7 +150,7 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
|
|
|
|
{i.type === 'posts' ? (
|
|
|
|
|
<PostListing
|
|
|
|
|
post={i.data as Post}
|
|
|
|
|
admins={this.state.admins}
|
|
|
|
|
admins={this.props.admins}
|
|
|
|
|
showCommunity
|
|
|
|
|
enableDownvotes={this.props.enableDownvotes}
|
|
|
|
|
enableNsfw={this.props.enableNsfw}
|
|
|
|
@ -160,7 +158,7 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
|
|
|
|
) : (
|
|
|
|
|
<CommentNodes
|
|
|
|
|
nodes={[{ comment: i.data as Comment }]}
|
|
|
|
|
admins={this.state.admins}
|
|
|
|
|
admins={this.props.admins}
|
|
|
|
|
noIndent
|
|
|
|
|
showContext
|
|
|
|
|
enableDownvotes={this.props.enableDownvotes}
|
|
|
|
@ -177,7 +175,7 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
|
|
|
|
<div>
|
|
|
|
|
<CommentNodes
|
|
|
|
|
nodes={commentsToFlatNodes(this.state.comments)}
|
|
|
|
|
admins={this.state.admins}
|
|
|
|
|
admins={this.props.admins}
|
|
|
|
|
noIndent
|
|
|
|
|
showContext
|
|
|
|
|
enableDownvotes={this.props.enableDownvotes}
|
|
|
|
@ -192,7 +190,7 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
|
|
|
|
{this.state.posts.map(post => (
|
|
|
|
|
<PostListing
|
|
|
|
|
post={post}
|
|
|
|
|
admins={this.state.admins}
|
|
|
|
|
admins={this.props.admins}
|
|
|
|
|
showCommunity
|
|
|
|
|
enableDownvotes={this.props.enableDownvotes}
|
|
|
|
|
enableNsfw={this.props.enableNsfw}
|
|
|
|
@ -252,7 +250,6 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
|
|
|
|
follows: data.follows,
|
|
|
|
|
moderates: data.moderates,
|
|
|
|
|
posts: data.posts,
|
|
|
|
|
admins: data.admins,
|
|
|
|
|
});
|
|
|
|
|
} else if (res.op == UserOperation.CreateCommentLike) {
|
|
|
|
|
const data = res.data as CommentResponse;
|
|
|
|
@ -298,11 +295,6 @@ export class UserDetails extends Component<UserDetailsProps, UserDetailsState> {
|
|
|
|
|
posts: this.state.posts,
|
|
|
|
|
comments: this.state.comments,
|
|
|
|
|
});
|
|
|
|
|
} else if (res.op == UserOperation.AddAdmin) {
|
|
|
|
|
const data = res.data as AddAdminResponse;
|
|
|
|
|
this.setState({
|
|
|
|
|
admins: data.admins,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|