Handle enable_nsfw correctly

This commit is contained in:
SleeplessOne1917 2024-04-15 07:20:22 -04:00
parent 9869b00fe0
commit afae55c2eb
2 changed files with 47 additions and 56 deletions

View file

@ -57,7 +57,7 @@ export class Signup extends Component<
registerRes: EMPTY_REQUEST,
captchaRes: EMPTY_REQUEST,
form: {
show_nsfw: false,
show_nsfw: !!this.isoData.site_res.site_view.site.content_warning,
},
captchaPlaying: false,
siteRes: this.isoData.site_res,
@ -261,27 +261,22 @@ export class Signup extends Component<
</>
)}
{this.renderCaptcha()}
{!this.state.siteRes.site_view.site.content_warning && (
<div className="mb-3 row">
<div className="col-sm-10">
<div className="form-check">
<input
className="form-check-input"
id="register-show-nsfw"
type="checkbox"
checked={this.state.form.show_nsfw}
onChange={linkEvent(this, this.handleRegisterShowNsfwChange)}
/>
<label
className="form-check-label"
htmlFor="register-show-nsfw"
>
{I18NextService.i18n.t("show_nsfw")}
</label>
</div>
<div className="mb-3 row">
<div className="col-sm-10">
<div className="form-check">
<input
className="form-check-input"
id="register-show-nsfw"
type="checkbox"
checked={this.state.form.show_nsfw}
onChange={linkEvent(this, this.handleRegisterShowNsfwChange)}
/>
<label className="form-check-label" htmlFor="register-show-nsfw">
{I18NextService.i18n.t("show_nsfw")}
</label>
</div>
</div>
)}
</div>
<input
tabIndex={-1}
autoComplete="false"

View file

@ -898,42 +898,38 @@ export class Settings extends Component<SettingsRouteProps, SettingsState> {
/>
</div>
</form>
{this.state.siteRes.site_view.local_site.enable_nsfw && (
<>
<div className="input-group mb-3">
<div className="form-check">
<input
className="form-check-input"
id="user-show-nsfw"
type="checkbox"
checked={this.state.saveUserSettingsForm.show_nsfw}
onChange={linkEvent(this, this.handleShowNsfwChange)}
/>
<label className="form-check-label" htmlFor="user-show-nsfw">
{I18NextService.i18n.t("show_nsfw")}
</label>
</div>
</div>
<div className="input-group mb-3">
<div className="form-check">
<input
className="form-check-input"
id="user-blur-nsfw"
type="checkbox"
disabled={!this.state.saveUserSettingsForm.show_nsfw}
checked={
this.state.saveUserSettingsForm.blur_nsfw &&
this.state.saveUserSettingsForm.show_nsfw
}
onChange={linkEvent(this, this.handleBlurNsfwChange)}
/>
<label className="form-check-label" htmlFor="user-blur-nsfw">
{I18NextService.i18n.t("blur_nsfw")}
</label>
</div>
</div>
</>
)}
<div className="input-group mb-3">
<div className="form-check">
<input
className="form-check-input"
id="user-show-nsfw"
type="checkbox"
checked={this.state.saveUserSettingsForm.show_nsfw}
onChange={linkEvent(this, this.handleShowNsfwChange)}
/>
<label className="form-check-label" htmlFor="user-show-nsfw">
{I18NextService.i18n.t("show_nsfw")}
</label>
</div>
</div>
<div className="input-group mb-3">
<div className="form-check">
<input
className="form-check-input"
id="user-blur-nsfw"
type="checkbox"
disabled={!this.state.saveUserSettingsForm.show_nsfw}
checked={
this.state.saveUserSettingsForm.blur_nsfw &&
this.state.saveUserSettingsForm.show_nsfw
}
onChange={linkEvent(this, this.handleBlurNsfwChange)}
/>
<label className="form-check-label" htmlFor="user-blur-nsfw">
{I18NextService.i18n.t("blur_nsfw")}
</label>
</div>
</div>
<div className="input-group mb-3">
<div className="form-check">
<input