Skip to content

Commit 9863e65

Browse files
committed
fix: do nothing on pressing giphy
1 parent e077674 commit 9863e65

File tree

1 file changed

+6
-47
lines changed
  • package/src/components/Attachment/Giphy

1 file changed

+6
-47
lines changed

package/src/components/Attachment/Giphy/Giphy.tsx

Lines changed: 6 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ import type { Attachment } from 'stream-chat';
55

66
import { GiphyImage } from './GiphyImage';
77

8-
import { ChatContextValue, useChatContext } from '../../../contexts/chatContext/ChatContext';
9-
10-
import {
11-
ImageGalleryContextValue,
12-
useImageGalleryContext,
13-
} from '../../../contexts/imageGalleryContext/ImageGalleryContext';
148
import {
159
MessageContextValue,
1610
useMessageContext,
@@ -19,39 +13,30 @@ import {
1913
MessagesContextValue,
2014
useMessagesContext,
2115
} from '../../../contexts/messagesContext/MessagesContext';
22-
import {
23-
OverlayContextValue,
24-
useOverlayContext,
25-
} from '../../../contexts/overlayContext/OverlayContext';
2616
import { useTheme } from '../../../contexts/themeContext/ThemeContext';
2717
import { useTranslationContext } from '../../../contexts/translationContext/TranslationContext';
2818

2919
import { EyeOpen } from '../../../icons/EyeOpen';
3020
import { primitives } from '../../../theme';
3121

32-
export type GiphyPropsWithContext = Pick<ImageGalleryContextValue, 'imageGalleryStateStore'> &
33-
Pick<
34-
MessageContextValue,
35-
'handleAction' | 'message' | 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'
36-
> &
37-
Pick<ChatContextValue, 'ImageComponent'> &
22+
export type GiphyPropsWithContext = Pick<
23+
MessageContextValue,
24+
'handleAction' | 'onLongPress' | 'onPress' | 'onPressIn' | 'preventPress'
25+
> &
3826
Pick<MessagesContextValue, 'additionalPressableProps' | 'giphyVersion'> & {
3927
attachment: Attachment;
40-
} & Pick<OverlayContextValue, 'setOverlay'>;
28+
};
4129

4230
const GiphyWithContext = (props: GiphyPropsWithContext) => {
4331
const {
4432
additionalPressableProps,
4533
attachment,
4634
giphyVersion,
4735
handleAction,
48-
imageGalleryStateStore,
49-
message,
5036
onLongPress,
5137
onPress,
5238
onPressIn,
5339
preventPress,
54-
setOverlay,
5540
} = props;
5641

5742
const { actions, image_url, thumb_url } = attachment;
@@ -78,14 +63,6 @@ const GiphyWithContext = (props: GiphyPropsWithContext) => {
7863

7964
const uri = image_url || thumb_url;
8065

81-
const defaultOnPress = () => {
82-
if (!uri) {
83-
return;
84-
}
85-
imageGalleryStateStore.openImageGallery({ messages: [message], selectedAttachmentUrl: uri });
86-
setOverlay('gallery');
87-
};
88-
8966
if (!uri) {
9067
return null;
9168
}
@@ -144,7 +121,6 @@ const GiphyWithContext = (props: GiphyPropsWithContext) => {
144121
onPress={(event) => {
145122
if (onPress) {
146123
onPress({
147-
defaultHandler: defaultOnPress,
148124
emitter: 'giphy',
149125
event,
150126
});
@@ -171,12 +147,10 @@ const areEqual = (prevProps: GiphyPropsWithContext, nextProps: GiphyPropsWithCon
171147
const {
172148
attachment: { actions: prevActions, image_url: prevImageUrl, thumb_url: prevThumbUrl },
173149
giphyVersion: prevGiphyVersion,
174-
message: prevMessage,
175150
} = prevProps;
176151
const {
177152
attachment: { actions: nextActions, image_url: nextImageUrl, thumb_url: nextThumbUrl },
178153
giphyVersion: nextGiphyVersion,
179-
message: nextMessage,
180154
} = nextProps;
181155

182156
const imageUrlEqual = prevImageUrl === nextImageUrl;
@@ -204,13 +178,6 @@ const areEqual = (prevProps: GiphyPropsWithContext, nextProps: GiphyPropsWithCon
204178
return false;
205179
}
206180

207-
const messageEqual =
208-
prevMessage?.id === nextMessage?.id &&
209-
`${prevMessage?.updated_at}` === `${nextMessage?.updated_at}`;
210-
211-
if (!messageEqual) {
212-
return false;
213-
}
214181
return true;
215182
};
216183

@@ -224,27 +191,19 @@ export type GiphyProps = Partial<GiphyPropsWithContext> & {
224191
* UI component for card in attachments.
225192
*/
226193
export const Giphy = (props: GiphyProps) => {
227-
const { handleAction, message, onLongPress, onPress, onPressIn, preventPress } =
228-
useMessageContext();
229-
const { ImageComponent } = useChatContext();
194+
const { handleAction, onLongPress, onPress, onPressIn, preventPress } = useMessageContext();
230195
const { additionalPressableProps, giphyVersion } = useMessagesContext();
231-
const { imageGalleryStateStore } = useImageGalleryContext();
232-
const { setOverlay } = useOverlayContext();
233196

234197
return (
235198
<MemoizedGiphy
236199
{...{
237200
additionalPressableProps,
238201
giphyVersion,
239202
handleAction,
240-
ImageComponent,
241-
imageGalleryStateStore,
242-
message,
243203
onLongPress,
244204
onPress,
245205
onPressIn,
246206
preventPress,
247-
setOverlay,
248207
}}
249208
{...props}
250209
/>

0 commit comments

Comments
 (0)