Category,
ListCategoriesResponse,
CommunityResponse,
+ GetSiteResponse,
} from '../interfaces';
import { WebSocketService } from '../services';
import { msgOp, capitalizeFirstLetter } from '../utils';
communityForm: CommunityFormI;
categories: Array<Category>;
loading: boolean;
+ enable_nsfw: boolean;
}
export class CommunityForm extends Component<
},
categories: [],
loading: false,
+ enable_nsfw: null,
};
constructor(props: any, context: any) {
);
WebSocketService.Instance.listCategories();
+ WebSocketService.Instance.getSite();
}
componentDidMount() {
</div>
</div>
- {WebSocketService.Instance.site.enable_nsfw && (
+ {this.state.enable_nsfw && (
<div class="form-group row">
<div class="col-12">
<div class="form-check">
let res: CommunityResponse = msg;
this.state.loading = false;
this.props.onEdit(res.community);
+ } else if (op == UserOperation.GetSite) {
+ let res: GetSiteResponse = msg;
+ this.state.enable_nsfw = res.site.enable_nsfw;
+ this.setState(this.state);
}
}
}
LoginResponse,
UserOperation,
PasswordResetForm,
+ GetSiteResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import { msgOp, validEmail } from '../utils';
registerForm: RegisterForm;
loginLoading: boolean;
registerLoading: boolean;
+ enable_nsfw: boolean;
}
export class Login extends Component<any, State> {
},
loginLoading: false,
registerLoading: false,
+ enable_nsfw: undefined,
};
constructor(props: any, context: any) {
err => console.error(err),
() => console.log('complete')
);
+
+ WebSocketService.Instance.getSite();
}
componentWillUnmount() {
this.subscription.unsubscribe();
}
- componentDidMount() {
- document.title = `${i18n.t('login')} - ${
- WebSocketService.Instance.site.name
- }`;
- }
-
render() {
return (
<div class="container">
/>
</div>
</div>
- {WebSocketService.Instance.site.enable_nsfw && (
+ {this.state.enable_nsfw && (
<div class="form-group row">
<div class="col-sm-10">
<div class="form-check">
this.props.history.push('/communities');
} else if (op == UserOperation.PasswordReset) {
alert(i18n.t('reset_password_mail_sent'));
+ } else if (op == UserOperation.GetSite) {
+ let res: GetSiteResponse = msg;
+ this.state.enable_nsfw = res.site.enable_nsfw;
+ this.setState(this.state);
+ document.title = `${i18n.t('login')} - ${
+ WebSocketService.Instance.site.name
+ }`;
}
}
}
SearchForm,
SearchType,
SearchResponse,
+ GetSiteResponse,
} from '../interfaces';
import { WebSocketService, UserService } from '../services';
import {
suggestedTitle: string;
suggestedPosts: Array<Post>;
crossPosts: Array<Post>;
+ enable_nsfw: boolean;
}
export class PostForm extends Component<PostFormProps, PostFormState> {
suggestedTitle: undefined,
suggestedPosts: [],
crossPosts: [],
+ enable_nsfw: undefined,
};
constructor(props: any, context: any) {
};
WebSocketService.Instance.listCommunities(listCommunitiesForm);
+ WebSocketService.Instance.getSite();
}
componentDidMount() {
</div>
</div>
)}
- {WebSocketService.Instance.site.enable_nsfw && (
+ {this.state.enable_nsfw && (
<div class="form-group row">
<div class="col-sm-10">
<div class="form-check">
this.state.crossPosts = res.posts;
}
this.setState(this.state);
+ } else if (op == UserOperation.GetSite) {
+ let res: GetSiteResponse = msg;
+ this.state.enable_nsfw = res.site.enable_nsfw;
+ this.setState(this.state);
}
}
}