mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-09-21 14:09:17 +02:00
fix image being blurred event if setting was off
This commit is contained in:
@@ -18,6 +18,7 @@ import { useRegisterSlide } from "../lightbox-provider";
|
|||||||
import { isImageURL } from "../../helpers/url";
|
import { isImageURL } from "../../helpers/url";
|
||||||
import PhotoGallery, { PhotoWithoutSize } from "../photo-gallery";
|
import PhotoGallery, { PhotoWithoutSize } from "../photo-gallery";
|
||||||
import { NostrEvent } from "../../types/nostr-event";
|
import { NostrEvent } from "../../types/nostr-event";
|
||||||
|
import useAppSettings from "../../hooks/use-app-settings";
|
||||||
|
|
||||||
function useElementBlur(initBlur = false): { style: CSSProperties; onClick: MouseEventHandler } {
|
function useElementBlur(initBlur = false): { style: CSSProperties; onClick: MouseEventHandler } {
|
||||||
const [blur, setBlur] = useState(initBlur);
|
const [blur, setBlur] = useState(initBlur);
|
||||||
@@ -41,6 +42,7 @@ function useElementBlur(initBlur = false): { style: CSSProperties; onClick: Mous
|
|||||||
export type TrustImageProps = ImageProps;
|
export type TrustImageProps = ImageProps;
|
||||||
|
|
||||||
export const TrustImage = forwardRef<HTMLImageElement, TrustImageProps>((props, ref) => {
|
export const TrustImage = forwardRef<HTMLImageElement, TrustImageProps>((props, ref) => {
|
||||||
|
const { blurImages } = useAppSettings();
|
||||||
const trusted = useTrusted();
|
const trusted = useTrusted();
|
||||||
const { onClick, style } = useElementBlur(!trusted);
|
const { onClick, style } = useElementBlur(!trusted);
|
||||||
|
|
||||||
@@ -54,7 +56,8 @@ export const TrustImage = forwardRef<HTMLImageElement, TrustImageProps>((props,
|
|||||||
[onClick, props.onClick],
|
[onClick, props.onClick],
|
||||||
);
|
);
|
||||||
|
|
||||||
return <Image {...props} onClick={handleClick} style={{ ...style, ...props.style }} ref={ref} />;
|
if (!blurImages) return <Image {...props} ref={ref} />;
|
||||||
|
else return <Image {...props} onClick={handleClick} style={{ ...style, ...props.style }} ref={ref} />;
|
||||||
});
|
});
|
||||||
|
|
||||||
export type EmbeddedImageProps = TrustImageProps & {
|
export type EmbeddedImageProps = TrustImageProps & {
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { useDisclosure } from "@chakra-ui/react";
|
import { useDisclosure } from "@chakra-ui/react";
|
||||||
import React, { PropsWithChildren, useContext, useMemo } from "react";
|
import React, { PropsWithChildren, useContext } from "react";
|
||||||
|
|
||||||
type ContextType = { expanded: boolean; onExpand: () => void; onCollapse: () => void; onToggle: () => void };
|
type ContextType = { expanded: boolean; onExpand: () => void; onCollapse: () => void; onToggle: () => void };
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user