diff --git a/api/typeDefs/user.js b/api/typeDefs/user.js index 3b755e5f..082782bf 100644 --- a/api/typeDefs/user.js +++ b/api/typeDefs/user.js @@ -84,6 +84,7 @@ export default gql` hideIsContributor: Boolean! hideWalletBalance: Boolean! imgproxyOnly: Boolean! + showImagesAndVideos: Boolean! nostrCrossposting: Boolean! nostrPubkey: String nostrRelays: [String!] @@ -155,6 +156,7 @@ export default gql` hideIsContributor: Boolean! hideWalletBalance: Boolean! imgproxyOnly: Boolean! + showImagesAndVideos: Boolean! nostrCrossposting: Boolean! nostrPubkey: String nostrRelays: [String!] diff --git a/components/image.js b/components/image.js index 05860cb0..493f70c5 100644 --- a/components/image.js +++ b/components/image.js @@ -19,13 +19,25 @@ export function decodeOriginalUrl (imgproxyUrl) { return originalUrl } -function ImageOriginal ({ src, topLevel, rel, tab, children, onClick, ...props }) { +function LinkRaw ({ href, children, src, rel, onClick, ...props }) { + const isRawURL = /^https?:\/\//.test(children?.[0]) + return ( + // eslint-disable-next-line + {isRawURL || !children ? src : children} + + ) +} + +function ImageOriginal ({ src, topLevel, tab, onClick, ...props }) { const me = useMe() const [showImage, setShowImage] = useState(false) const [showVideo, setShowVideo] = useState(false) useEffect(() => { - if (me?.privates?.imgproxyOnly && tab !== 'preview') return // make sure it's not a false negative by trying to load URL as const img = new window.Image() img.onload = () => setShowImage(true) @@ -42,7 +54,9 @@ function ImageOriginal ({ src, topLevel, rel, tab, children, onClick, ...props } } }, [src, showImage]) - if (showImage) { + const showMedia = (tab === 'preview' || (me?.privates?.showImagesAndVideos !== false && !me?.privates?.imgproxyOnly)) + + if (showImage && showMedia) { return ( setShowImage(false)} /> ) - } else if (showVideo) { + } else if (showVideo && showMedia) { return