summaryrefslogtreecommitdiffstats
path: root/ui/src/components/user.tsx
diff options
context:
space:
mode:
authorFilip785 <fdjuricic98@gmail.com>2020-07-08 17:21:44 +0200
committerFilip785 <fdjuricic98@gmail.com>2020-07-08 17:21:44 +0200
commite7b7b0dee30356ef6912168949112896fe4dd65c (patch)
tree3ab0abc410a4da218c08b45349824585afa8cb6c /ui/src/components/user.tsx
parent68e9755e593bbd8230eab2a123e822022721f071 (diff)
parentcd5f500d11d131213ccb89d3a8c9f5e31b3c758b (diff)
Merge remote-tracking branch 'upstream/master' into cake-day
Diffstat (limited to 'ui/src/components/user.tsx')
-rw-r--r--ui/src/components/user.tsx38
1 files changed, 35 insertions, 3 deletions
diff --git a/ui/src/components/user.tsx b/ui/src/components/user.tsx
index 4f680324..7e679ed1 100644
--- a/ui/src/components/user.tsx
+++ b/ui/src/components/user.tsx
@@ -20,6 +20,8 @@ import {
DeleteAccountForm,
PostResponse,
WebSocketJsonResponse,
+ GetSiteResponse,
+ Site,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import {
@@ -75,6 +77,7 @@ interface UserState {
deleteAccountLoading: boolean;
deleteAccountShowConfirm: boolean;
deleteAccountForm: DeleteAccountForm;
+ site: Site;
}
export class User extends Component<any, UserState> {
@@ -123,6 +126,20 @@ export class User extends Component<any, UserState> {
deleteAccountForm: {
password: null,
},
+ site: {
+ id: undefined,
+ name: undefined,
+ creator_id: undefined,
+ published: undefined,
+ creator_name: undefined,
+ number_of_users: undefined,
+ number_of_posts: undefined,
+ number_of_comments: undefined,
+ number_of_communities: undefined,
+ enable_downvotes: undefined,
+ open_registration: undefined,
+ enable_nsfw: undefined,
+ },
};
constructor(props: any, context: any) {
@@ -149,6 +166,7 @@ export class User extends Component<any, UserState> {
);
this.refetch();
+ WebSocketService.Instance.getSite();
}
get isCurrentUser() {
@@ -357,6 +375,8 @@ export class User extends Component<any, UserState> {
post={i.data as Post}
admins={this.state.admins}
showCommunity
+ enableDownvotes={this.state.site.enable_downvotes}
+ enableNsfw={this.state.site.enable_nsfw}
/>
) : (
<CommentNodes
@@ -364,6 +384,7 @@ export class User extends Component<any, UserState> {
admins={this.state.admins}
noIndent
showContext
+ enableDownvotes={this.state.site.enable_downvotes}
/>
)}
</div>
@@ -380,6 +401,7 @@ export class User extends Component<any, UserState> {
admins={this.state.admins}
noIndent
showContext
+ enableDownvotes={this.state.site.enable_downvotes}
/>
</div>
);
@@ -389,7 +411,13 @@ export class User extends Component<any, UserState> {
return (
<div>
{this.state.posts.map(post => (
- <PostListing post={post} admins={this.state.admins} showCommunity />
+ <PostListing
+ post={post}
+ admins={this.state.admins}
+ showCommunity
+ enableDownvotes={this.state.site.enable_downvotes}
+ enableNsfw={this.state.site.enable_nsfw}
+ />
))}
</div>
);
@@ -680,7 +708,7 @@ export class User extends Component<any, UserState> {
/>
</div>
</div>
- {WebSocketService.Instance.site.enable_nsfw && (
+ {this.state.site.enable_nsfw && (
<div class="form-group">
<div class="form-check">
<input
@@ -1117,7 +1145,7 @@ export class User extends Component<any, UserState> {
UserService.Instance.user.show_avatars;
this.state.userSettingsForm.matrix_user_id = this.state.user.matrix_user_id;
}
- document.title = `/u/${this.state.user.name} - ${WebSocketService.Instance.site.name}`;
+ document.title = `/u/${this.state.user.name} - ${this.state.site.name}`;
window.scrollTo(0, 0);
this.setState(this.state);
setupTippy();
@@ -1169,6 +1197,10 @@ export class User extends Component<any, UserState> {
this.state.deleteAccountShowConfirm = false;
this.setState(this.state);
this.context.router.history.push('/');
+ } else if (res.op == UserOperation.GetSite) {
+ let data = res.data as GetSiteResponse;
+ this.state.site = data.site;
+ this.setState(this.state);
}
}
}