fix image being blurred event if setting was off

This commit is contained in:
hzrd149
2023-08-22 14:13:34 -05:00
parent 6325e16cc2
commit 3f400547c8
2 changed files with 5 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ import { useRegisterSlide } from "../lightbox-provider";
import { isImageURL } from "../../helpers/url";
import PhotoGallery, { PhotoWithoutSize } from "../photo-gallery";
import { NostrEvent } from "../../types/nostr-event";
import useAppSettings from "../../hooks/use-app-settings";
function useElementBlur(initBlur = false): { style: CSSProperties; onClick: MouseEventHandler } {
const [blur, setBlur] = useState(initBlur);
@@ -41,6 +42,7 @@ function useElementBlur(initBlur = false): { style: CSSProperties; onClick: Mous
export type TrustImageProps = ImageProps;
export const TrustImage = forwardRef<HTMLImageElement, TrustImageProps>((props, ref) => {
const { blurImages } = useAppSettings();
const trusted = useTrusted();
const { onClick, style } = useElementBlur(!trusted);
@@ -54,7 +56,8 @@ export const TrustImage = forwardRef<HTMLImageElement, TrustImageProps>((props,
[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 & {

View File

@@ -1,5 +1,5 @@
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 };