mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-29 07:41:13 +00:00
Fix blur and adjust user settings
This commit is contained in:
parent
d51cf751b5
commit
b1fc470ba0
4 changed files with 52 additions and 33 deletions
|
@ -1,9 +1,9 @@
|
|||
import classNames from "classnames";
|
||||
import { Component } from "inferno";
|
||||
|
||||
import { UserService } from "../../services";
|
||||
import { setIsoData } from "@utils/app";
|
||||
import { IsoDataOptionalSite } from "shared/interfaces";
|
||||
import { shouldBlurNsfw } from "@utils/helpers";
|
||||
|
||||
const iconThumbnailSize = 96;
|
||||
const thumbnailSize = 256;
|
||||
|
@ -31,10 +31,7 @@ export class PictrsImage extends Component<PictrsImageProps, any> {
|
|||
const { src, icon, iconOverlay, banner, thumbnail, nsfw, pushup, cardTop } =
|
||||
this.props;
|
||||
|
||||
const blurImage =
|
||||
nsfw &&
|
||||
(!this.isoData.site_res?.site_view.site.content_warning ||
|
||||
UserService.Instance.myUserInfo?.local_user_view.local_user.blur_nsfw);
|
||||
const blurImage = nsfw && shouldBlurNsfw(this.isoData.site_res);
|
||||
|
||||
return (
|
||||
<picture>
|
||||
|
|
|
@ -898,34 +898,42 @@ export class Settings extends Component<SettingsRouteProps, SettingsState> {
|
|||
/>
|
||||
</div>
|
||||
</form>
|
||||
<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"
|
||||
checked={this.state.saveUserSettingsForm.blur_nsfw}
|
||||
onChange={linkEvent(this, this.handleBlurNsfwChange)}
|
||||
/>
|
||||
<label className="form-check-label" htmlFor="user-blur-nsfw">
|
||||
{I18NextService.i18n.t("blur_nsfw")}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
{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
|
||||
|
|
|
@ -25,6 +25,7 @@ import validTitle from "./valid-title";
|
|||
import validURL from "./valid-url";
|
||||
import dedupByProperty from "./dedup-by-property";
|
||||
import getApubName from "./apub-name";
|
||||
import shouldBlurNsfw from "./should-blur-nsfw";
|
||||
|
||||
export {
|
||||
capitalizeFirstLetter,
|
||||
|
@ -54,4 +55,5 @@ export {
|
|||
validURL,
|
||||
dedupByProperty,
|
||||
getApubName,
|
||||
shouldBlurNsfw,
|
||||
};
|
||||
|
|
12
src/shared/utils/helpers/should-blur-nsfw.ts
Normal file
12
src/shared/utils/helpers/should-blur-nsfw.ts
Normal file
|
@ -0,0 +1,12 @@
|
|||
import { SiteResponse } from "lemmy-js-client";
|
||||
import { adultConsentLocalStorageKey } from "../../config";
|
||||
import { UserService } from "../../services";
|
||||
|
||||
export default function shouldBlurNsfw(siteRes?: SiteResponse) {
|
||||
return siteRes?.site_view.site.content_warning
|
||||
? !(
|
||||
localStorage.getItem(adultConsentLocalStorageKey) ||
|
||||
UserService.Instance.myUserInfo
|
||||
)
|
||||
: UserService.Instance.myUserInfo?.local_user_view.local_user.blur_nsfw;
|
||||
}
|
Loading…
Reference in a new issue