diff --git a/src/components/Attachment/Attachment.js b/src/components/Attachment/Attachment.js index f9f05bf334..8c886eec26 100644 --- a/src/components/Attachment/Attachment.js +++ b/src/components/Attachment/Attachment.js @@ -34,8 +34,8 @@ const Attachment = (props) => { return null; } - const Giphy = props?.Giphy || Card; - const UrlPreview = props?.UrlPreview || Card; + const Giphy = props && props.Giphy ? props.Giphy : Card; + const UrlPreview = props && props.UrlPreview ? props.UrlPreview : Card; const cardProps = { Header: CardHeader ? CardHeader : undefined, Cover: CardCover ? CardCover : undefined, @@ -61,11 +61,12 @@ const Attachment = (props) => { type = 'card'; } + const hasAttachmentActions = attachment.actions && attachment.actions.length; if (type === 'image') { return ( <> - {attachment.actions?.length && ( + {hasAttachmentActions && ( { } if (type === 'giphy') { - if (attachment.actions?.length) { + if (hasAttachmentActions) { return ( @@ -94,7 +95,7 @@ const Attachment = (props) => { } if (type === 'card') { - if (attachment.actions?.length) { + if (hasAttachmentActions) { return ( diff --git a/src/components/Attachment/Gallery.js b/src/components/Attachment/Gallery.js index ff1e01cd45..a85bcafc66 100644 --- a/src/components/Attachment/Gallery.js +++ b/src/components/Attachment/Gallery.js @@ -95,7 +95,7 @@ const Gallery = ({ alignment, images }) => { const [viewerModalImageIndex, setViewerModalImageIndex] = useState(0); const [viewerModalOpen, setViewerModalOpen] = useState(false); - if (!images?.length) return null; + if (!images || !images.length) return null; const galleryImages = [...images].map((image) => ({ url: makeImageCompatibleUrl(image.image_url || image.thumb_url), diff --git a/src/components/ChannelPreview/ChannelPreviewMessenger.js b/src/components/ChannelPreview/ChannelPreviewMessenger.js index f1714b2d37..86516ead6a 100644 --- a/src/components/ChannelPreview/ChannelPreviewMessenger.js +++ b/src/components/ChannelPreview/ChannelPreviewMessenger.js @@ -89,7 +89,8 @@ const ChannelPreviewMessenger = ({ 0 ? unread : undefined}> - {latestMessage?.text && + {latestMessage && + latestMessage.text && truncate(latestMessage.text.replace(/\n/g, ' '), { length: latestMessageLength, })} diff --git a/src/components/SuggestionsProvider/SuggestionsProvider.js b/src/components/SuggestionsProvider/SuggestionsProvider.js index 2f9cd7891e..424c7051ee 100644 --- a/src/components/SuggestionsProvider/SuggestionsProvider.js +++ b/src/components/SuggestionsProvider/SuggestionsProvider.js @@ -54,20 +54,25 @@ const SuggestionsProvider = ({ children }) => { const getInputBoxPosition = () => new Promise((resolve) => { const nodeHandleRoot = findNodeHandle(rootView.current); - messageInputBox.current?.measureLayout( - nodeHandleRoot, - (x, y, width, height) => { - resolve({ x, y, height, width }); - }, - ); + messageInputBox.current && + messageInputBox.current.measureLayout( + nodeHandleRoot, + (x, y, width, height) => { + resolve({ x, y, height, width }); + }, + ); }); const getChatBoxPosition = () => new Promise((resolve) => { const nodeHandleRoot = findNodeHandle(rootView.current); - rootView.current?.measureLayout(nodeHandleRoot, (x, y, width, height) => { - resolve({ x, y, height, width }); - }); + rootView.current && + rootView.current.measureLayout( + nodeHandleRoot, + (x, y, width, height) => { + resolve({ x, y, height, width }); + }, + ); }); const suggestionsContext = { diff --git a/src/components/docs/Gallery.md b/src/components/docs/Gallery.md index 3a5e26e9b9..972470deab 100644 --- a/src/components/docs/Gallery.md +++ b/src/components/docs/Gallery.md @@ -1,11 +1,13 @@ ```js const images = [ - { image_url: 'https://i.picsum.photos/id/1/200/300.jpg' }, - { image_url: 'https://i.picsum.photos/id/2/200/300.jpg' }, - { image_url: 'https://i.picsum.photos/id/3/200/300.jpg' }, - { image_url: 'https://i.picsum.photos/id/4/200/300.jpg' }, - { image_url: 'https://i.picsum.photos/id/5/200/300.jpg' }, - { image_url: 'https://i.picsum.photos/id/6/200/300.jpg' }, + { image_url: 'https://i.picsum.photos/id/912/200/300.jpg?blur=5&hmac=Qk9-L9x5NUPVQh1fgIM_HucJtpX2RKOAK1sLTGD-7U4' }, + { image_url: 'https://i.picsum.photos/id/1/5616/3744.jpg?hmac=kKHwwU8s46oNettHKwJ24qOlIAsWN9d2TtsXDoCWWsQ' }, + { image_url: 'https://i.picsum.photos/id/10/2500/1667.jpg?hmac=J04WWC_ebchx3WwzbM-Z4_KC_LeLBWr5LZMaAkWkF68' }, + { image_url: 'https://i.picsum.photos/id/100/2500/1656.jpg?hmac=gWyN-7ZB32rkAjMhKXQgdHOIBRHyTSgzuOK6U0vXb1w' }, + { image_url: 'https://i.picsum.photos/id/912/200/300.jpg?blur=5&hmac=Qk9-L9x5NUPVQh1fgIM_HucJtpX2RKOAK1sLTGD-7U4' }, + { image_url: 'https://i.picsum.photos/id/912/200/300.jpg?blur=5&hmac=Qk9-L9x5NUPVQh1fgIM_HucJtpX2RKOAK1sLTGD-7U4' }, ]; -; + + ; + ```