mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-25 22:01: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,6 +898,8 @@ 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
|
||||
|
@ -918,7 +920,11 @@ export class Settings extends Component<SettingsRouteProps, SettingsState> {
|
|||
className="form-check-input"
|
||||
id="user-blur-nsfw"
|
||||
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)}
|
||||
/>
|
||||
<label className="form-check-label" htmlFor="user-blur-nsfw">
|
||||
|
@ -926,6 +932,8 @@ export class Settings extends Component<SettingsRouteProps, SettingsState> {
|
|||
</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