mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-12 19:06:13 +00:00
Fix blur and adjust user settings
This commit is contained in:
parent
d51cf751b5
commit
b1fc470ba0
|
@ -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,34 +898,42 @@ export class Settings extends Component<SettingsRouteProps, SettingsState> {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<div className="input-group mb-3">
|
{this.state.siteRes.site_view.local_site.enable_nsfw && (
|
||||||
<div className="form-check">
|
<>
|
||||||
<input
|
<div className="input-group mb-3">
|
||||||
className="form-check-input"
|
<div className="form-check">
|
||||||
id="user-show-nsfw"
|
<input
|
||||||
type="checkbox"
|
className="form-check-input"
|
||||||
checked={this.state.saveUserSettingsForm.show_nsfw}
|
id="user-show-nsfw"
|
||||||
onChange={linkEvent(this, this.handleShowNsfwChange)}
|
type="checkbox"
|
||||||
/>
|
checked={this.state.saveUserSettingsForm.show_nsfw}
|
||||||
<label className="form-check-label" htmlFor="user-show-nsfw">
|
onChange={linkEvent(this, this.handleShowNsfwChange)}
|
||||||
{I18NextService.i18n.t("show_nsfw")}
|
/>
|
||||||
</label>
|
<label className="form-check-label" htmlFor="user-show-nsfw">
|
||||||
</div>
|
{I18NextService.i18n.t("show_nsfw")}
|
||||||
</div>
|
</label>
|
||||||
<div className="input-group mb-3">
|
</div>
|
||||||
<div className="form-check">
|
</div>
|
||||||
<input
|
<div className="input-group mb-3">
|
||||||
className="form-check-input"
|
<div className="form-check">
|
||||||
id="user-blur-nsfw"
|
<input
|
||||||
type="checkbox"
|
className="form-check-input"
|
||||||
checked={this.state.saveUserSettingsForm.blur_nsfw}
|
id="user-blur-nsfw"
|
||||||
onChange={linkEvent(this, this.handleBlurNsfwChange)}
|
type="checkbox"
|
||||||
/>
|
disabled={!this.state.saveUserSettingsForm.show_nsfw}
|
||||||
<label className="form-check-label" htmlFor="user-blur-nsfw">
|
checked={
|
||||||
{I18NextService.i18n.t("blur_nsfw")}
|
this.state.saveUserSettingsForm.blur_nsfw &&
|
||||||
</label>
|
this.state.saveUserSettingsForm.show_nsfw
|
||||||
</div>
|
}
|
||||||
</div>
|
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="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