| 
									
										
										
										
											2023-01-03 11:55:46 -08:00
										 |  |  | // Copyright 2018 Signal Messenger, LLC
 | 
					
						
							| 
									
										
										
										
											2020-10-30 15:34:04 -05:00
										 |  |  | // SPDX-License-Identifier: AGPL-3.0-only
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  | import React from 'react'; | 
					
						
							|  |  |  | import classNames from 'classnames'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { AttachmentType } from '../../types/Attachment'; | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  | import { | 
					
						
							| 
									
										
										
										
											2019-01-14 13:49:58 -08:00
										 |  |  |   areAllAttachmentsVisual, | 
					
						
							|  |  |  |   getAlt, | 
					
						
							|  |  |  |   getImageDimensions, | 
					
						
							|  |  |  |   getThumbnailUrl, | 
					
						
							|  |  |  |   getUrl, | 
					
						
							|  |  |  |   isVideoAttachment, | 
					
						
							|  |  |  | } from '../../types/Attachment'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-27 16:03:50 -07:00
										 |  |  | import { Image, CurveType } from './Image'; | 
					
						
							| 
									
										
										
										
											2019-01-14 13:49:58 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-10-26 14:15:33 -05:00
										 |  |  | import type { LocalizerType, ThemeType } from '../../types/Util'; | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-27 16:03:50 -07:00
										 |  |  | export type DirectionType = 'incoming' | 'outgoing'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-01-14 12:07:05 -06:00
										 |  |  | export type Props = { | 
					
						
							| 
									
										
										
										
											2022-12-21 16:07:02 -08:00
										 |  |  |   attachments: ReadonlyArray<AttachmentType>; | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |   bottomOverlay?: boolean; | 
					
						
							| 
									
										
										
										
											2022-04-27 16:03:50 -07:00
										 |  |  |   direction: DirectionType; | 
					
						
							| 
									
										
										
										
											2019-05-16 15:32:11 -07:00
										 |  |  |   isSticker?: boolean; | 
					
						
							| 
									
										
										
										
											2022-04-27 16:03:50 -07:00
										 |  |  |   shouldCollapseAbove?: boolean; | 
					
						
							|  |  |  |   shouldCollapseBelow?: boolean; | 
					
						
							| 
									
										
										
										
											2019-05-16 15:32:11 -07:00
										 |  |  |   stickerSize?: number; | 
					
						
							| 
									
										
										
										
											2019-11-07 13:36:16 -08:00
										 |  |  |   tabIndex?: number; | 
					
						
							| 
									
										
										
										
											2022-04-27 16:03:50 -07:00
										 |  |  |   withContentAbove?: boolean; | 
					
						
							|  |  |  |   withContentBelow?: boolean; | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-14 13:49:58 -08:00
										 |  |  |   i18n: LocalizerType; | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |   theme?: ThemeType; | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   onError: () => void; | 
					
						
							| 
									
										
										
										
											2019-03-15 15:18:00 -07:00
										 |  |  |   onClick?: (attachment: AttachmentType) => void; | 
					
						
							| 
									
										
										
										
											2021-01-14 12:07:05 -06:00
										 |  |  | }; | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  | const GAP = 1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-27 16:03:50 -07:00
										 |  |  | function getCurves({ | 
					
						
							|  |  |  |   direction, | 
					
						
							|  |  |  |   shouldCollapseAbove, | 
					
						
							|  |  |  |   shouldCollapseBelow, | 
					
						
							|  |  |  |   withContentAbove, | 
					
						
							|  |  |  |   withContentBelow, | 
					
						
							|  |  |  | }: { | 
					
						
							|  |  |  |   direction: DirectionType; | 
					
						
							|  |  |  |   shouldCollapseAbove?: boolean; | 
					
						
							|  |  |  |   shouldCollapseBelow?: boolean; | 
					
						
							|  |  |  |   withContentAbove?: boolean; | 
					
						
							|  |  |  |   withContentBelow?: boolean; | 
					
						
							|  |  |  | }): { | 
					
						
							|  |  |  |   curveTopLeft: CurveType; | 
					
						
							|  |  |  |   curveTopRight: CurveType; | 
					
						
							|  |  |  |   curveBottomLeft: CurveType; | 
					
						
							|  |  |  |   curveBottomRight: CurveType; | 
					
						
							|  |  |  | } { | 
					
						
							|  |  |  |   let curveTopLeft = CurveType.None; | 
					
						
							|  |  |  |   let curveTopRight = CurveType.None; | 
					
						
							|  |  |  |   let curveBottomLeft = CurveType.None; | 
					
						
							|  |  |  |   let curveBottomRight = CurveType.None; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (shouldCollapseAbove && direction === 'incoming') { | 
					
						
							|  |  |  |     curveTopLeft = CurveType.Tiny; | 
					
						
							|  |  |  |     curveTopRight = CurveType.Normal; | 
					
						
							|  |  |  |   } else if (shouldCollapseAbove && direction === 'outgoing') { | 
					
						
							|  |  |  |     curveTopLeft = CurveType.Normal; | 
					
						
							|  |  |  |     curveTopRight = CurveType.Tiny; | 
					
						
							|  |  |  |   } else if (!withContentAbove) { | 
					
						
							|  |  |  |     curveTopLeft = CurveType.Normal; | 
					
						
							|  |  |  |     curveTopRight = CurveType.Normal; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (shouldCollapseBelow && direction === 'incoming') { | 
					
						
							|  |  |  |     curveBottomLeft = CurveType.Tiny; | 
					
						
							|  |  |  |     curveBottomRight = CurveType.None; | 
					
						
							|  |  |  |   } else if (shouldCollapseBelow && direction === 'outgoing') { | 
					
						
							|  |  |  |     curveBottomLeft = CurveType.None; | 
					
						
							|  |  |  |     curveBottomRight = CurveType.Tiny; | 
					
						
							|  |  |  |   } else if (!withContentBelow) { | 
					
						
							|  |  |  |     curveBottomLeft = CurveType.Normal; | 
					
						
							|  |  |  |     curveBottomRight = CurveType.Normal; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return { | 
					
						
							|  |  |  |     curveTopLeft, | 
					
						
							|  |  |  |     curveTopRight, | 
					
						
							|  |  |  |     curveBottomLeft, | 
					
						
							|  |  |  |     curveBottomRight, | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | export function ImageGrid({ | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   attachments, | 
					
						
							|  |  |  |   bottomOverlay, | 
					
						
							| 
									
										
										
										
											2022-04-27 16:03:50 -07:00
										 |  |  |   direction, | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   i18n, | 
					
						
							|  |  |  |   isSticker, | 
					
						
							|  |  |  |   stickerSize, | 
					
						
							|  |  |  |   onError, | 
					
						
							|  |  |  |   onClick, | 
					
						
							| 
									
										
										
										
											2022-04-27 16:03:50 -07:00
										 |  |  |   shouldCollapseAbove, | 
					
						
							|  |  |  |   shouldCollapseBelow, | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   tabIndex, | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |   theme, | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   withContentAbove, | 
					
						
							|  |  |  |   withContentBelow, | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | }: Props): JSX.Element | null { | 
					
						
							| 
									
										
										
										
											2022-04-27 16:03:50 -07:00
										 |  |  |   const { curveTopLeft, curveTopRight, curveBottomLeft, curveBottomRight } = | 
					
						
							|  |  |  |     getCurves({ | 
					
						
							|  |  |  |       direction, | 
					
						
							|  |  |  |       shouldCollapseAbove, | 
					
						
							|  |  |  |       shouldCollapseBelow, | 
					
						
							|  |  |  |       withContentAbove, | 
					
						
							|  |  |  |       withContentBelow, | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-04-27 16:03:50 -07:00
										 |  |  |   const withBottomOverlay = Boolean(bottomOverlay && !withContentBelow); | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   if (!attachments || !attachments.length) { | 
					
						
							|  |  |  |     return null; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-01-14 13:49:58 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   if (attachments.length === 1 || !areAllAttachmentsVisual(attachments)) { | 
					
						
							|  |  |  |     const { height, width } = getImageDimensions( | 
					
						
							|  |  |  |       attachments[0], | 
					
						
							|  |  |  |       isSticker ? stickerSize : undefined | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |     return ( | 
					
						
							|  |  |  |       <div | 
					
						
							|  |  |  |         className={classNames( | 
					
						
							|  |  |  |           'module-image-grid', | 
					
						
							|  |  |  |           'module-image-grid--one-image', | 
					
						
							|  |  |  |           isSticker ? 'module-image-grid--with-sticker' : null | 
					
						
							|  |  |  |         )} | 
					
						
							|  |  |  |       > | 
					
						
							|  |  |  |         <Image | 
					
						
							|  |  |  |           alt={getAlt(attachments[0], i18n)} | 
					
						
							|  |  |  |           i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |           theme={theme} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |           blurHash={attachments[0].blurHash} | 
					
						
							|  |  |  |           bottomOverlay={withBottomOverlay} | 
					
						
							|  |  |  |           noBorder={isSticker} | 
					
						
							|  |  |  |           noBackground={isSticker} | 
					
						
							|  |  |  |           curveTopLeft={curveTopLeft} | 
					
						
							|  |  |  |           curveTopRight={curveTopRight} | 
					
						
							|  |  |  |           curveBottomLeft={curveBottomLeft} | 
					
						
							|  |  |  |           curveBottomRight={curveBottomRight} | 
					
						
							|  |  |  |           attachment={attachments[0]} | 
					
						
							|  |  |  |           playIconOverlay={isVideoAttachment(attachments[0])} | 
					
						
							|  |  |  |           height={height} | 
					
						
							|  |  |  |           width={width} | 
					
						
							|  |  |  |           url={getUrl(attachments[0])} | 
					
						
							|  |  |  |           tabIndex={tabIndex} | 
					
						
							|  |  |  |           onClick={onClick} | 
					
						
							|  |  |  |           onError={onError} | 
					
						
							|  |  |  |         /> | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-05-16 15:32:11 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   if (attachments.length === 2) { | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <div className="module-image-grid"> | 
					
						
							|  |  |  |         <Image | 
					
						
							|  |  |  |           alt={getAlt(attachments[0], i18n)} | 
					
						
							|  |  |  |           i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |           theme={theme} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |           attachment={attachments[0]} | 
					
						
							|  |  |  |           blurHash={attachments[0].blurHash} | 
					
						
							|  |  |  |           bottomOverlay={withBottomOverlay} | 
					
						
							|  |  |  |           noBorder={false} | 
					
						
							|  |  |  |           curveTopLeft={curveTopLeft} | 
					
						
							|  |  |  |           curveBottomLeft={curveBottomLeft} | 
					
						
							|  |  |  |           playIconOverlay={isVideoAttachment(attachments[0])} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |           height={150} | 
					
						
							|  |  |  |           width={150} | 
					
						
							|  |  |  |           cropWidth={GAP} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |           url={getThumbnailUrl(attachments[0])} | 
					
						
							|  |  |  |           onClick={onClick} | 
					
						
							|  |  |  |           onError={onError} | 
					
						
							|  |  |  |         /> | 
					
						
							|  |  |  |         <Image | 
					
						
							|  |  |  |           alt={getAlt(attachments[1], i18n)} | 
					
						
							|  |  |  |           i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |           theme={theme} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |           blurHash={attachments[1].blurHash} | 
					
						
							|  |  |  |           bottomOverlay={withBottomOverlay} | 
					
						
							|  |  |  |           noBorder={false} | 
					
						
							|  |  |  |           curveTopRight={curveTopRight} | 
					
						
							|  |  |  |           curveBottomRight={curveBottomRight} | 
					
						
							|  |  |  |           playIconOverlay={isVideoAttachment(attachments[1])} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |           height={150} | 
					
						
							|  |  |  |           width={150} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |           attachment={attachments[1]} | 
					
						
							|  |  |  |           url={getThumbnailUrl(attachments[1])} | 
					
						
							|  |  |  |           onClick={onClick} | 
					
						
							|  |  |  |           onError={onError} | 
					
						
							|  |  |  |         /> | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   if (attachments.length === 3) { | 
					
						
							|  |  |  |     return ( | 
					
						
							|  |  |  |       <div className="module-image-grid"> | 
					
						
							|  |  |  |         <Image | 
					
						
							|  |  |  |           alt={getAlt(attachments[0], i18n)} | 
					
						
							|  |  |  |           i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |           theme={theme} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |           blurHash={attachments[0].blurHash} | 
					
						
							|  |  |  |           bottomOverlay={withBottomOverlay} | 
					
						
							|  |  |  |           noBorder={false} | 
					
						
							|  |  |  |           curveTopLeft={curveTopLeft} | 
					
						
							|  |  |  |           curveBottomLeft={curveBottomLeft} | 
					
						
							|  |  |  |           attachment={attachments[0]} | 
					
						
							|  |  |  |           playIconOverlay={isVideoAttachment(attachments[0])} | 
					
						
							|  |  |  |           height={200} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |           width={200} | 
					
						
							|  |  |  |           cropWidth={GAP} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |           url={getUrl(attachments[0])} | 
					
						
							|  |  |  |           onClick={onClick} | 
					
						
							|  |  |  |           onError={onError} | 
					
						
							|  |  |  |         /> | 
					
						
							|  |  |  |         <div className="module-image-grid__column"> | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |           <Image | 
					
						
							|  |  |  |             alt={getAlt(attachments[1], i18n)} | 
					
						
							|  |  |  |             i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |             theme={theme} | 
					
						
							| 
									
										
										
										
											2020-05-27 17:37:06 -04:00
										 |  |  |             blurHash={attachments[1].blurHash} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |             curveTopRight={curveTopRight} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |             height={100} | 
					
						
							|  |  |  |             width={100} | 
					
						
							|  |  |  |             cropHeight={GAP} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |             attachment={attachments[1]} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             playIconOverlay={isVideoAttachment(attachments[1])} | 
					
						
							| 
									
										
										
										
											2019-01-11 16:41:39 -08:00
										 |  |  |             url={getThumbnailUrl(attachments[1])} | 
					
						
							| 
									
										
										
										
											2019-03-15 15:18:00 -07:00
										 |  |  |             onClick={onClick} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |             onError={onError} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |           <Image | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             alt={getAlt(attachments[2], i18n)} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |             i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |             theme={theme} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             blurHash={attachments[2].blurHash} | 
					
						
							| 
									
										
										
										
											2019-01-14 13:49:58 -08:00
										 |  |  |             bottomOverlay={withBottomOverlay} | 
					
						
							| 
									
										
										
										
											2019-11-07 13:36:16 -08:00
										 |  |  |             noBorder={false} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             curveBottomRight={curveBottomRight} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |             height={100} | 
					
						
							|  |  |  |             width={100} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             attachment={attachments[2]} | 
					
						
							|  |  |  |             playIconOverlay={isVideoAttachment(attachments[2])} | 
					
						
							|  |  |  |             url={getThumbnailUrl(attachments[2])} | 
					
						
							| 
									
										
										
										
											2019-03-15 15:18:00 -07:00
										 |  |  |             onClick={onClick} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |             onError={onError} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |         </div> | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |       </div> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-01-14 13:49:58 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |   if (attachments.length === 4) { | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |     return ( | 
					
						
							|  |  |  |       <div className="module-image-grid"> | 
					
						
							|  |  |  |         <div className="module-image-grid__column"> | 
					
						
							|  |  |  |           <div className="module-image-grid__row"> | 
					
						
							|  |  |  |             <Image | 
					
						
							|  |  |  |               alt={getAlt(attachments[0], i18n)} | 
					
						
							|  |  |  |               i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |               theme={theme} | 
					
						
							| 
									
										
										
										
											2020-05-27 17:37:06 -04:00
										 |  |  |               blurHash={attachments[0].blurHash} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |               curveTopLeft={curveTopLeft} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |               noBorder={false} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |               attachment={attachments[0]} | 
					
						
							|  |  |  |               playIconOverlay={isVideoAttachment(attachments[0])} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |               height={150} | 
					
						
							|  |  |  |               width={150} | 
					
						
							|  |  |  |               cropHeight={GAP} | 
					
						
							|  |  |  |               cropWidth={GAP} | 
					
						
							| 
									
										
										
										
											2019-01-11 16:41:39 -08:00
										 |  |  |               url={getThumbnailUrl(attachments[0])} | 
					
						
							| 
									
										
										
										
											2019-03-15 15:18:00 -07:00
										 |  |  |               onClick={onClick} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |               onError={onError} | 
					
						
							|  |  |  |             /> | 
					
						
							|  |  |  |             <Image | 
					
						
							|  |  |  |               alt={getAlt(attachments[1], i18n)} | 
					
						
							|  |  |  |               i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |               theme={theme} | 
					
						
							| 
									
										
										
										
											2020-05-27 17:37:06 -04:00
										 |  |  |               blurHash={attachments[1].blurHash} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |               curveTopRight={curveTopRight} | 
					
						
							|  |  |  |               playIconOverlay={isVideoAttachment(attachments[1])} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |               noBorder={false} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |               height={150} | 
					
						
							|  |  |  |               width={150} | 
					
						
							|  |  |  |               cropHeight={GAP} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |               attachment={attachments[1]} | 
					
						
							| 
									
										
										
										
											2019-01-11 16:41:39 -08:00
										 |  |  |               url={getThumbnailUrl(attachments[1])} | 
					
						
							| 
									
										
										
										
											2019-03-15 15:18:00 -07:00
										 |  |  |               onClick={onClick} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |               onError={onError} | 
					
						
							|  |  |  |             /> | 
					
						
							|  |  |  |           </div> | 
					
						
							|  |  |  |           <div className="module-image-grid__row"> | 
					
						
							|  |  |  |             <Image | 
					
						
							|  |  |  |               alt={getAlt(attachments[2], i18n)} | 
					
						
							|  |  |  |               i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |               theme={theme} | 
					
						
							| 
									
										
										
										
											2020-05-27 17:37:06 -04:00
										 |  |  |               blurHash={attachments[2].blurHash} | 
					
						
							| 
									
										
										
										
											2019-01-14 13:49:58 -08:00
										 |  |  |               bottomOverlay={withBottomOverlay} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |               noBorder={false} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |               curveBottomLeft={curveBottomLeft} | 
					
						
							|  |  |  |               playIconOverlay={isVideoAttachment(attachments[2])} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |               height={150} | 
					
						
							|  |  |  |               width={150} | 
					
						
							|  |  |  |               cropWidth={GAP} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |               attachment={attachments[2]} | 
					
						
							| 
									
										
										
										
											2019-01-11 16:41:39 -08:00
										 |  |  |               url={getThumbnailUrl(attachments[2])} | 
					
						
							| 
									
										
										
										
											2019-03-15 15:18:00 -07:00
										 |  |  |               onClick={onClick} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |               onError={onError} | 
					
						
							|  |  |  |             /> | 
					
						
							|  |  |  |             <Image | 
					
						
							|  |  |  |               alt={getAlt(attachments[3], i18n)} | 
					
						
							|  |  |  |               i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |               theme={theme} | 
					
						
							| 
									
										
										
										
											2020-05-27 17:37:06 -04:00
										 |  |  |               blurHash={attachments[3].blurHash} | 
					
						
							| 
									
										
										
										
											2019-01-14 13:49:58 -08:00
										 |  |  |               bottomOverlay={withBottomOverlay} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |               noBorder={false} | 
					
						
							|  |  |  |               curveBottomRight={curveBottomRight} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |               playIconOverlay={isVideoAttachment(attachments[3])} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |               height={150} | 
					
						
							|  |  |  |               width={150} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |               attachment={attachments[3]} | 
					
						
							| 
									
										
										
										
											2019-01-11 16:41:39 -08:00
										 |  |  |               url={getThumbnailUrl(attachments[3])} | 
					
						
							| 
									
										
										
										
											2019-03-15 15:18:00 -07:00
										 |  |  |               onClick={onClick} | 
					
						
							| 
									
										
										
										
											2018-11-14 10:47:19 -08:00
										 |  |  |               onError={onError} | 
					
						
							|  |  |  |             /> | 
					
						
							|  |  |  |           </div> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   const moreMessagesOverlay = attachments.length > 5; | 
					
						
							|  |  |  |   const moreMessagesOverlayText = moreMessagesOverlay | 
					
						
							|  |  |  |     ? `+${attachments.length - 5}` | 
					
						
							|  |  |  |     : undefined; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <div className="module-image-grid"> | 
					
						
							|  |  |  |       <div className="module-image-grid__column"> | 
					
						
							|  |  |  |         <div className="module-image-grid__row"> | 
					
						
							|  |  |  |           <Image | 
					
						
							|  |  |  |             alt={getAlt(attachments[0], i18n)} | 
					
						
							|  |  |  |             i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |             theme={theme} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             blurHash={attachments[0].blurHash} | 
					
						
							|  |  |  |             curveTopLeft={curveTopLeft} | 
					
						
							|  |  |  |             attachment={attachments[0]} | 
					
						
							|  |  |  |             playIconOverlay={isVideoAttachment(attachments[0])} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |             height={150} | 
					
						
							|  |  |  |             width={150} | 
					
						
							|  |  |  |             cropWidth={GAP} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             url={getThumbnailUrl(attachments[0])} | 
					
						
							|  |  |  |             onClick={onClick} | 
					
						
							|  |  |  |             onError={onError} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |           <Image | 
					
						
							|  |  |  |             alt={getAlt(attachments[1], i18n)} | 
					
						
							|  |  |  |             i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |             theme={theme} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             blurHash={attachments[1].blurHash} | 
					
						
							|  |  |  |             curveTopRight={curveTopRight} | 
					
						
							|  |  |  |             playIconOverlay={isVideoAttachment(attachments[1])} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |             height={150} | 
					
						
							|  |  |  |             width={150} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             attachment={attachments[1]} | 
					
						
							|  |  |  |             url={getThumbnailUrl(attachments[1])} | 
					
						
							|  |  |  |             onClick={onClick} | 
					
						
							|  |  |  |             onError={onError} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |         <div className="module-image-grid__row"> | 
					
						
							|  |  |  |           <Image | 
					
						
							|  |  |  |             alt={getAlt(attachments[2], i18n)} | 
					
						
							|  |  |  |             i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |             theme={theme} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             blurHash={attachments[2].blurHash} | 
					
						
							|  |  |  |             bottomOverlay={withBottomOverlay} | 
					
						
							|  |  |  |             noBorder={isSticker} | 
					
						
							|  |  |  |             curveBottomLeft={curveBottomLeft} | 
					
						
							|  |  |  |             playIconOverlay={isVideoAttachment(attachments[2])} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |             height={100} | 
					
						
							|  |  |  |             width={100} | 
					
						
							|  |  |  |             cropWidth={GAP} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             attachment={attachments[2]} | 
					
						
							|  |  |  |             url={getThumbnailUrl(attachments[2])} | 
					
						
							|  |  |  |             onClick={onClick} | 
					
						
							|  |  |  |             onError={onError} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |           <Image | 
					
						
							|  |  |  |             alt={getAlt(attachments[3], i18n)} | 
					
						
							|  |  |  |             i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |             theme={theme} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             blurHash={attachments[3].blurHash} | 
					
						
							|  |  |  |             bottomOverlay={withBottomOverlay} | 
					
						
							|  |  |  |             noBorder={isSticker} | 
					
						
							|  |  |  |             playIconOverlay={isVideoAttachment(attachments[3])} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |             height={100} | 
					
						
							|  |  |  |             width={100} | 
					
						
							|  |  |  |             cropWidth={GAP} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             attachment={attachments[3]} | 
					
						
							|  |  |  |             url={getThumbnailUrl(attachments[3])} | 
					
						
							|  |  |  |             onClick={onClick} | 
					
						
							|  |  |  |             onError={onError} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |           <Image | 
					
						
							|  |  |  |             alt={getAlt(attachments[4], i18n)} | 
					
						
							|  |  |  |             i18n={i18n} | 
					
						
							| 
									
										
										
										
											2021-02-11 20:50:11 -05:00
										 |  |  |             theme={theme} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             blurHash={attachments[4].blurHash} | 
					
						
							|  |  |  |             bottomOverlay={withBottomOverlay} | 
					
						
							|  |  |  |             noBorder={isSticker} | 
					
						
							|  |  |  |             curveBottomRight={curveBottomRight} | 
					
						
							|  |  |  |             playIconOverlay={isVideoAttachment(attachments[4])} | 
					
						
							| 
									
										
										
										
											2021-06-24 14:00:11 -07:00
										 |  |  |             height={100} | 
					
						
							|  |  |  |             width={100} | 
					
						
							| 
									
										
										
										
											2020-09-14 12:51:27 -07:00
										 |  |  |             darkOverlay={moreMessagesOverlay} | 
					
						
							|  |  |  |             overlayText={moreMessagesOverlayText} | 
					
						
							|  |  |  |             attachment={attachments[4]} | 
					
						
							|  |  |  |             url={getThumbnailUrl(attachments[4])} | 
					
						
							|  |  |  |             onClick={onClick} | 
					
						
							|  |  |  |             onError={onError} | 
					
						
							|  |  |  |           /> | 
					
						
							|  |  |  |         </div> | 
					
						
							|  |  |  |       </div> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ); | 
					
						
							| 
									
										
										
										
											2022-11-17 16:45:19 -08:00
										 |  |  | } |