diff --git a/package-lock.json b/package-lock.json index de50ecae..5fd5b686 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cinny", - "version": "4.7.0", + "version": "4.7.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "cinny", - "version": "4.7.0", + "version": "4.7.1", "license": "AGPL-3.0-only", "dependencies": { "@atlaskit/pragmatic-drag-and-drop": "1.1.6", diff --git a/package.json b/package.json index 0f2d439b..983cbe4f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cinny", - "version": "4.7.0", + "version": "4.7.1", "description": "Yet another matrix client", "main": "index.js", "type": "module", diff --git a/src/app/components/message/content/ImageContent.tsx b/src/app/components/message/content/ImageContent.tsx index 69c7ade8..cc0c0c91 100644 --- a/src/app/components/message/content/ImageContent.tsx +++ b/src/app/components/message/content/ImageContent.tsx @@ -30,6 +30,7 @@ import { stopPropagation } from '../../../utils/keyboard'; import { decryptFile, downloadEncryptedMedia, mxcUrlToHttp } from '../../../utils/matrix'; import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication'; import { ModalWide } from '../../../styles/Modal.css'; +import { validBlurHash } from '../../../utils/blurHash'; type RenderViewerProps = { src: string; @@ -77,7 +78,7 @@ export const ImageContent = as<'div', ImageContentProps>( ) => { const mx = useMatrixClient(); const useAuthentication = useMediaAuthentication(); - const blurHash = info?.[MATRIX_BLUR_HASH_PROPERTY_NAME]; + const blurHash = validBlurHash(info?.[MATRIX_BLUR_HASH_PROPERTY_NAME]); const [load, setLoad] = useState(false); const [error, setError] = useState(false); diff --git a/src/app/components/message/content/VideoContent.tsx b/src/app/components/message/content/VideoContent.tsx index f6ddbb5a..0505f204 100644 --- a/src/app/components/message/content/VideoContent.tsx +++ b/src/app/components/message/content/VideoContent.tsx @@ -31,6 +31,7 @@ import { mxcUrlToHttp, } from '../../../utils/matrix'; import { useMediaAuthentication } from '../../../hooks/useMediaAuthentication'; +import { validBlurHash } from '../../../utils/blurHash'; type RenderVideoProps = { title: string; @@ -68,7 +69,7 @@ export const VideoContent = as<'div', VideoContentProps>( ) => { const mx = useMatrixClient(); const useAuthentication = useMediaAuthentication(); - const blurHash = info.thumbnail_info?.[MATRIX_BLUR_HASH_PROPERTY_NAME]; + const blurHash = validBlurHash(info.thumbnail_info?.[MATRIX_BLUR_HASH_PROPERTY_NAME]); const [load, setLoad] = useState(false); const [error, setError] = useState(false); diff --git a/src/app/pages/auth/AuthFooter.tsx b/src/app/pages/auth/AuthFooter.tsx index 90ae3dd8..fbb6e01b 100644 --- a/src/app/pages/auth/AuthFooter.tsx +++ b/src/app/pages/auth/AuthFooter.tsx @@ -15,7 +15,7 @@ export function AuthFooter() { target="_blank" rel="noreferrer" > - v4.7.0 + v4.7.1 Twitter diff --git a/src/app/pages/client/WelcomePage.tsx b/src/app/pages/client/WelcomePage.tsx index 461b8d0d..99d70647 100644 --- a/src/app/pages/client/WelcomePage.tsx +++ b/src/app/pages/client/WelcomePage.tsx @@ -24,7 +24,7 @@ export function WelcomePage() { target="_blank" rel="noreferrer noopener" > - v4.7.0 + v4.7.1 } diff --git a/src/app/utils/blurHash.ts b/src/app/utils/blurHash.ts index 3fe1ade0..566f6d18 100644 --- a/src/app/utils/blurHash.ts +++ b/src/app/utils/blurHash.ts @@ -1,4 +1,4 @@ -import { encode } from 'blurhash'; +import { encode, isBlurhashValid } from 'blurhash'; export const encodeBlurHash = ( img: HTMLImageElement | HTMLVideoElement, @@ -17,3 +17,13 @@ export const encodeBlurHash = ( const data = context.getImageData(0, 0, canvas.width, canvas.height); return encode(data.data, data.width, data.height, 4, 4); }; + +export const validBlurHash = (hash?: string): string | undefined => { + if (typeof hash === 'string') { + const validity = isBlurhashValid(hash); + + return validity.result ? hash : undefined; + } + + return undefined; +}; diff --git a/src/client/state/cons.js b/src/client/state/cons.js index 35144ce5..ae746f7a 100644 --- a/src/client/state/cons.js +++ b/src/client/state/cons.js @@ -1,5 +1,5 @@ const cons = { - version: '4.7.0', + version: '4.7.1', secretKey: { ACCESS_TOKEN: 'cinny_access_token', DEVICE_ID: 'cinny_device_id',