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 classNames from "classnames";
|
||||||
import { Component } from "inferno";
|
import { Component } from "inferno";
|
||||||
|
|
||||||
import { UserService } from "../../services";
|
|
||||||
import { setIsoData } from "@utils/app";
|
import { setIsoData } from "@utils/app";
|
||||||
import { IsoDataOptionalSite } from "shared/interfaces";
|
import { IsoDataOptionalSite } from "shared/interfaces";
|
||||||
|
import { shouldBlurNsfw } from "@utils/helpers";
|
||||||
|
|
||||||
const iconThumbnailSize = 96;
|
const iconThumbnailSize = 96;
|
||||||
const thumbnailSize = 256;
|
const thumbnailSize = 256;
|
||||||
|
@ -31,10 +31,7 @@ export class PictrsImage extends Component<PictrsImageProps, any> {
|
||||||
const { src, icon, iconOverlay, banner, thumbnail, nsfw, pushup, cardTop } =
|
const { src, icon, iconOverlay, banner, thumbnail, nsfw, pushup, cardTop } =
|
||||||
this.props;
|
this.props;
|
||||||
|
|
||||||
const blurImage =
|
const blurImage = nsfw && shouldBlurNsfw(this.isoData.site_res);
|
||||||
nsfw &&
|
|
||||||
(!this.isoData.site_res?.site_view.site.content_warning ||
|
|
||||||
UserService.Instance.myUserInfo?.local_user_view.local_user.blur_nsfw);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<picture>
|
<picture>
|
||||||
|
|
|
@ -898,6 +898,8 @@ export class Settings extends Component<SettingsRouteProps, SettingsState> {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
{this.state.siteRes.site_view.local_site.enable_nsfw && (
|
||||||
|
<>
|
||||||
<div className="input-group mb-3">
|
<div className="input-group mb-3">
|
||||||
<div className="form-check">
|
<div className="form-check">
|
||||||
<input
|
<input
|
||||||
|
@ -918,7 +920,11 @@ export class Settings extends Component<SettingsRouteProps, SettingsState> {
|
||||||
className="form-check-input"
|
className="form-check-input"
|
||||||
id="user-blur-nsfw"
|
id="user-blur-nsfw"
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
checked={this.state.saveUserSettingsForm.blur_nsfw}
|
disabled={!this.state.saveUserSettingsForm.show_nsfw}
|
||||||
|
checked={
|
||||||
|
this.state.saveUserSettingsForm.blur_nsfw &&
|
||||||
|
this.state.saveUserSettingsForm.show_nsfw
|
||||||
|
}
|
||||||
onChange={linkEvent(this, this.handleBlurNsfwChange)}
|
onChange={linkEvent(this, this.handleBlurNsfwChange)}
|
||||||
/>
|
/>
|
||||||
<label className="form-check-label" htmlFor="user-blur-nsfw">
|
<label className="form-check-label" htmlFor="user-blur-nsfw">
|
||||||
|
@ -926,6 +932,8 @@ export class Settings extends Component<SettingsRouteProps, SettingsState> {
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
<div className="input-group mb-3">
|
<div className="input-group mb-3">
|
||||||
<div className="form-check">
|
<div className="form-check">
|
||||||
<input
|
<input
|
||||||
|
|
|
@ -25,6 +25,7 @@ import validTitle from "./valid-title";
|
||||||
import validURL from "./valid-url";
|
import validURL from "./valid-url";
|
||||||
import dedupByProperty from "./dedup-by-property";
|
import dedupByProperty from "./dedup-by-property";
|
||||||
import getApubName from "./apub-name";
|
import getApubName from "./apub-name";
|
||||||
|
import shouldBlurNsfw from "./should-blur-nsfw";
|
||||||
|
|
||||||
export {
|
export {
|
||||||
capitalizeFirstLetter,
|
capitalizeFirstLetter,
|
||||||
|
@ -54,4 +55,5 @@ export {
|
||||||
validURL,
|
validURL,
|
||||||
dedupByProperty,
|
dedupByProperty,
|
||||||
getApubName,
|
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