@@ -36,10 +36,7 @@ import { isVideoPlayerAvailable } from '../../native';
3636import { FileTypes } from '../../types/types' ;
3737import { getUrlWithoutParams } from '../../utils/utils' ;
3838
39- export type GalleryPropsWithContext = Pick <
40- ImageGalleryContextValue ,
41- 'setSelectedMessage' | 'setMessages'
42- > &
39+ export type GalleryPropsWithContext = Pick < ImageGalleryContextValue , 'imageGalleryStateStore' > &
4340 Pick <
4441 MessageContextValue ,
4542 | 'alignment'
@@ -73,6 +70,7 @@ const GalleryWithContext = (props: GalleryPropsWithContext) => {
7370 alignment,
7471 groupStyles,
7572 hasThreadReplies,
73+ imageGalleryStateStore,
7674 ImageLoadingFailedIndicator,
7775 ImageLoadingIndicator,
7876 ImageReloadIndicator,
@@ -82,9 +80,7 @@ const GalleryWithContext = (props: GalleryPropsWithContext) => {
8280 onPress,
8381 onPressIn,
8482 preventPress,
85- setMessages,
8683 setOverlay,
87- setSelectedMessage,
8884 threadList,
8985 videos,
9086 VideoThumbnail,
@@ -190,6 +186,7 @@ const GalleryWithContext = (props: GalleryPropsWithContext) => {
190186 additionalPressableProps = { additionalPressableProps }
191187 borderRadius = { borderRadius }
192188 colIndex = { colIndex }
189+ imageGalleryStateStore = { imageGalleryStateStore }
193190 ImageLoadingFailedIndicator = { ImageLoadingFailedIndicator }
194191 ImageLoadingIndicator = { ImageLoadingIndicator }
195192 ImageReloadIndicator = { ImageReloadIndicator }
@@ -204,9 +201,7 @@ const GalleryWithContext = (props: GalleryPropsWithContext) => {
204201 onPressIn = { onPressIn }
205202 preventPress = { preventPress }
206203 rowIndex = { rowIndex }
207- setMessages = { setMessages }
208204 setOverlay = { setOverlay }
209- setSelectedMessage = { setSelectedMessage }
210205 thumbnail = { thumbnail }
211206 VideoThumbnail = { VideoThumbnail }
212207 />
@@ -242,14 +237,15 @@ type GalleryThumbnailProps = {
242237 | 'ImageLoadingFailedIndicator'
243238 | 'ImageReloadIndicator'
244239> &
245- Pick < ImageGalleryContextValue , 'setSelectedMessage' | 'setMessages '> &
240+ Pick < ImageGalleryContextValue , 'imageGalleryStateStore ' > &
246241 Pick < MessageContextValue , 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress' > &
247242 Pick < OverlayContextValue , 'setOverlay' > ;
248243
249244const GalleryThumbnail = ( {
250245 additionalPressableProps,
251246 borderRadius,
252247 colIndex,
248+ imageGalleryStateStore,
253249 ImageLoadingFailedIndicator,
254250 ImageLoadingIndicator,
255251 ImageReloadIndicator,
@@ -263,9 +259,7 @@ const GalleryThumbnail = ({
263259 onPressIn,
264260 preventPress,
265261 rowIndex,
266- setMessages,
267262 setOverlay,
268- setSelectedMessage,
269263 thumbnail,
270264 VideoThumbnail,
271265} : GalleryThumbnailProps ) => {
@@ -288,8 +282,8 @@ const GalleryThumbnail = ({
288282
289283 const openImageViewer = ( ) => {
290284 if ( message ) {
291- setMessages ( [ message ] ) ;
292- setSelectedMessage ( { messageId : message . id , url : thumbnail . url } ) ;
285+ imageGalleryStateStore . message = message ;
286+ imageGalleryStateStore . selectedAttachmentUrl = thumbnail . url ;
293287 setOverlay ( 'gallery' ) ;
294288 }
295289 } ;
@@ -562,13 +556,12 @@ export const Gallery = (props: GalleryProps) => {
562556 onPressIn : propOnPressIn ,
563557 preventPress : propPreventPress ,
564558 setOverlay : propSetOverlay ,
565- setSelectedMessage : propSetSelectedMessage ,
566559 threadList : propThreadList ,
567560 videos : propVideos ,
568561 VideoThumbnail : PropVideoThumbnail ,
569562 } = props ;
570563
571- const { setMessages , setSelectedMessage : contextSetSelectedMessage } = useImageGalleryContext ( ) ;
564+ const { imageGalleryStateStore } = useImageGalleryContext ( ) ;
572565 const {
573566 alignment : contextAlignment ,
574567 groupStyles : contextGroupStyles ,
@@ -607,7 +600,6 @@ export const Gallery = (props: GalleryProps) => {
607600 const onPress = propOnPress || contextOnPress ;
608601 const preventPress =
609602 typeof propPreventPress === 'boolean' ? propPreventPress : contextPreventPress ;
610- const setSelectedMessage = propSetSelectedMessage || contextSetSelectedMessage ;
611603 const setOverlay = propSetOverlay || contextSetOverlay ;
612604 const threadList = propThreadList || contextThreadList ;
613605 const VideoThumbnail = PropVideoThumbnail || ContextVideoThumnbnail ;
@@ -625,6 +617,7 @@ export const Gallery = (props: GalleryProps) => {
625617 channelId : message ?. cid ,
626618 groupStyles,
627619 hasThreadReplies : hasThreadReplies || ! ! message ?. reply_count ,
620+ imageGalleryStateStore,
628621 ImageLoadingFailedIndicator,
629622 ImageLoadingIndicator,
630623 ImageReloadIndicator,
@@ -635,9 +628,7 @@ export const Gallery = (props: GalleryProps) => {
635628 onPress,
636629 onPressIn,
637630 preventPress,
638- setMessages,
639631 setOverlay,
640- setSelectedMessage,
641632 threadList,
642633 videos,
643634 VideoThumbnail,
0 commit comments