@cometchat/chat-uikit-react-native 4.3.1 → 4.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/android/src/main/AndroidManifest.xml +3 -4
  2. package/android/src/main/java/com/reactnativecometchatuikit/CometchatUiKitPackage.java +0 -1
  3. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +125 -7
  4. package/android/src/main/java/com/reactnativecometchatuikit/ImageManager.java +1 -1
  5. package/package.json +1 -1
  6. package/src/CometChatConversations/CometChatConversations.tsx +51 -28
  7. package/src/CometChatConversations/style.ts +5 -1
  8. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +53 -20
  9. package/src/CometChatMessageList/CometChatMessageList.tsx +15 -15
  10. package/src/CometChatMessageList/MessageListConfiguration.ts +5 -5
  11. package/src/CometChatThreadedMessages/CometChatThreadedMessages.tsx +35 -2
  12. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +51 -15
  13. package/src/index.ts +8 -8
  14. package/src/shared/CometChatContext.tsx +5 -1
  15. package/src/shared/CometChatUiKit/CometChatUIKit.ts +1 -4
  16. package/src/shared/index.ts +8 -8
  17. package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +1040 -0
  18. package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +223 -0
  19. package/src/shared/libs/ImageZoom/helper.ts +144 -0
  20. package/src/shared/libs/ImageZoom/index.tsx +13 -0
  21. package/src/shared/libs/ImageZoom/types/index.ts +186 -0
  22. package/src/shared/libs/VideoPlayer/Video.js +0 -24
  23. package/src/shared/libs/VideoPlayerControls/assets/img/back.png +0 -0
  24. package/src/shared/libs/VideoPlayerControls/components/Back/Back.tsx +1 -1
  25. package/src/shared/resources/CometChatLocalize/CometChatLocalize.ts +1 -1
  26. package/src/shared/utils/NetworkUtils.tsx +5 -0
  27. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -0
  28. package/src/shared/views/CometChatDate/CometChatDate.tsx +1 -1
  29. package/src/shared/views/CometChatImageBubble/CometChatImageBubble.tsx +64 -18
  30. package/src/shared/views/CometChatImageBubble/assets/index.ts +5 -0
  31. package/src/shared/views/CometChatImageBubble/assets/spineer.png +0 -0
  32. package/src/shared/views/CometChatImageViewerModal/ImageViewerModal.tsx +106 -0
  33. package/src/shared/views/CometChatImageViewerModal/index.tsx +1 -0
  34. package/src/shared/views/CometChatImageViewerModal/resources/Back.png +0 -0
  35. package/src/shared/views/CometChatImageViewerModal/resources/index.ts +5 -0
  36. package/src/shared/views/CometChatList/CometChatList.tsx +10 -1
  37. package/src/shared/views/{CometChatReactionsList/CometChatReactionsList.tsx → CometChatReactionList/CometChatReactionList.tsx} +17 -17
  38. package/src/shared/views/CometChatReactionList/ReactionListConfiguration.tsx +14 -0
  39. package/src/shared/views/CometChatReactionList/index.ts +12 -0
  40. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +1 -1
  41. package/src/shared/views/index.ts +5 -5
  42. package/android/src/main/java/com/reactnativecometchatuikit/VideoManager.java +0 -40
  43. package/src/shared/libs/VideoPlayerControls/assets/img/back@2x.png +0 -0
  44. package/src/shared/libs/VideoPlayerControls/assets/img/back@3x.png +0 -0
  45. package/src/shared/views/CometChatReactionsList/ReactionsListConfiguration.tsx +0 -14
  46. package/src/shared/views/CometChatReactionsList/index.ts +0 -12
  47. /package/src/shared/views/{CometChatReactionsList/ReactionsListStyle.tsx → CometChatReactionList/ReactionListStyle.tsx} +0 -0
  48. /package/src/shared/views/{CometChatReactionsList → CometChatReactionList}/resources/Spineer.png +0 -0
  49. /package/src/shared/views/{CometChatReactionsList → CometChatReactionList}/resources/index.ts +0 -0
@@ -22,7 +22,7 @@ import {
22
22
  import { DateStyleInterface } from '../shared/views/CometChatDate/DateStyle';
23
23
  import { ActionSheetStylesInterface } from '../shared/views/CometChatActionSheet/ActionSheetStyle';
24
24
  import { ReactionsConfigurationInterface } from '../shared/views/CometChatReactions';
25
- import { ReactionsListConfigurationInterface } from '../shared/views/CometChatReactionsList';
25
+ import { ReactionListConfigurationInterface } from '../shared/views/CometChatReactionList';
26
26
  import { QuickReactionsConfigurationInterface } from '../shared/views/CometChatQuickReactions';
27
27
  import { EmojiKeyboardStyle } from '../shared/views/CometChatEmojiKeyboard';
28
28
 
@@ -82,9 +82,9 @@ export interface MessageListConfigurationInterface {
82
82
  */
83
83
  reactionsConfiguration?: ReactionsConfigurationInterface;
84
84
  /**
85
- * Message Reaction List Configuration @ReactionsListConfigurationInterface
85
+ * Message Reaction List Configuration @ReactionListConfigurationInterface
86
86
  */
87
- reactionsListConfiguration?: ReactionsListConfigurationInterface;
87
+ reactionListConfiguration?: ReactionListConfigurationInterface;
88
88
  /**
89
89
  * Quick Reaction Configuration @QuickReactionsConfigurationInterface
90
90
  */
@@ -155,9 +155,9 @@ export class MessageListConfiguration
155
155
  */
156
156
  reactionsConfiguration?: ReactionsConfigurationInterface;
157
157
  /**
158
- * Message Reaction List Configuration @ReactionsListConfigurationInterface
158
+ * Message Reaction List Configuration @ReactionListConfigurationInterface
159
159
  */
160
- reactionsListConfiguration?: ReactionsListConfigurationInterface;
160
+ reactionListConfiguration?: ReactionListConfigurationInterface;
161
161
  /**
162
162
  * Quick Reaction Configuration @QuickReactionsConfigurationInterface
163
163
  */
@@ -132,10 +132,20 @@ export const CometChatThreadedMessages = (
132
132
 
133
133
  let limit: number = 30;
134
134
 
135
+ const checkMessageBelongsToSameThread = (updatedMessage : CometChat.BaseMessage)=>{
136
+
137
+ return (updatedMessage.getParentMessageId() == message.getId() );
138
+ }
139
+
140
+ const checkAndUpdateRepliesCount = ( updatedMessage : CometChat.BaseMessage)=>{
141
+ if(checkMessageBelongsToSameThread(updatedMessage)){
142
+ setReplyCount((prev) => prev + 1);
143
+ }
144
+ }
145
+
135
146
  const ccMessageSentFunc = ({ message: msg, status }) => {
136
147
  if (status === messageStatus.success) {
137
- if (message.getId() == msg.parentMessageId)
138
- setReplyCount((prev) => prev + 1);
148
+ checkAndUpdateRepliesCount(msg)
139
149
  if (message.getId() == msg.id) setMessage(message);
140
150
  }
141
151
  };
@@ -150,12 +160,35 @@ export const CometChatThreadedMessages = (
150
160
  if (message.getId() == msg.id) setMessage(message);
151
161
  };
152
162
 
163
+
164
+
153
165
  useEffect(() => {
154
166
  CometChatUIEventHandler.addMessageListener(uiEventId, {
155
167
  ccMessageSent: (item) => ccMessageSentFunc(item),
156
168
  ccMessageEdited: (item) => ccMessageEditedFunc(item),
157
169
  ccMessageDeleted: (item) => ccMessageDeletedFunc(item),
158
170
  ccMessageRead: (item) => ccMessageReadFunc(item),
171
+ onTextMessageReceived: (textMessage) => {
172
+ checkAndUpdateRepliesCount(textMessage)
173
+ },
174
+ onMediaMessageReceived: (mediaMessage) => {
175
+ checkAndUpdateRepliesCount(mediaMessage)
176
+ },
177
+ onCustomMessageReceived: (customMessage) => {
178
+ checkAndUpdateRepliesCount(customMessage)
179
+ },
180
+ onFormMessageReceived: (formMessage) => {
181
+ checkAndUpdateRepliesCount(formMessage)
182
+ },
183
+ onCardMessageReceived: (cardMessage) => {
184
+ checkAndUpdateRepliesCount(cardMessage)
185
+ },
186
+ onSchedulerMessageReceived: (schedulerMessage) => {
187
+ checkAndUpdateRepliesCount(schedulerMessage)
188
+ },
189
+ onCustomInteractiveMessageReceived: (customInteractiveMessage) => {
190
+ checkAndUpdateRepliesCount(customInteractiveMessage)
191
+ }
159
192
  });
160
193
 
161
194
  return () => {
@@ -1,5 +1,5 @@
1
- import React, { useState } from 'react'
2
- import { View, Text, TouchableOpacity, Linking, Image, Alert } from 'react-native'
1
+ import React, { useEffect, useRef, useState } from "react";
2
+ import { View, Text, TouchableOpacity, Linking, Image, Alert, Platform } from 'react-native'
3
3
  import { LinkPreviewBubbleStyle, LinkPreviewBubbleStyleInterface } from './LInkPreviewBubbleStyle';
4
4
  import { localize } from '../../shared/resources/CometChatLocalize';
5
5
  import { DefaultLinkPreview } from "./resources";
@@ -30,20 +30,53 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
30
30
 
31
31
  const [imageSource, setImageSource] = useState({ uri: image.startsWith("https:") ? image : `https:${image.split("http:")[1]}` });
32
32
 
33
+
34
+ const pressTime = useRef(0);
35
+
36
+ const handleTouchStart = () => {
37
+ pressTime.current = Date.now();
38
+ };
39
+
40
+ const handleTouchEnd = () => {
41
+ if (pressTime.current === null && Platform.OS === "ios") return;
42
+ const endTime = Date.now();
43
+ const pressDuration = endTime - pressTime.current;
44
+ if (pressDuration < 500) {
45
+ onPress ? onPress() : (Linking.canOpenURL(link) && Linking.openURL(link)) || Alert.alert(localize("SOMETHING_WRONG"))
46
+ }
47
+ };
48
+
49
+ const onTouchMove = () => {
50
+ if (Platform.OS === "ios") {
51
+ pressTime.current = null;
52
+ }
53
+ }
54
+
55
+
33
56
  return (
34
- <TouchableOpacity style={{
35
- backgroundColor: _style.backgroundColor,
36
- borderRadius: 8,
37
- }}
38
- onPress={() => onPress ? onPress() : (Linking.canOpenURL(link) && Linking.openURL(link)) || Alert.alert(localize("SOMETHING_WRONG"))}
39
- >
40
- <Image
41
- source={imageSource }
42
- style={{ height: 100, width: "100%", alignSelf: "center" }}
43
- onError={(err) => {
44
- setImageSource(DefaultLinkPreview)
57
+ <View>
58
+
59
+ <View
60
+ style={{
61
+ backgroundColor: _style.backgroundColor,
62
+ borderRadius: 8,
45
63
  }}
46
- />
64
+ onTouchStart={handleTouchStart}
65
+ onTouchEnd={handleTouchEnd}
66
+ onTouchMove={onTouchMove}
67
+ >
68
+
69
+ <Image
70
+ source={imageSource}
71
+ style={{ height: 100, width: "100%", alignSelf: "center" }}
72
+ onError={(err) => {
73
+ setImageSource(DefaultLinkPreview)
74
+ }}
75
+ />
76
+
77
+
78
+ </View>
79
+
47
80
  <View style={{ margin: 8 }}>
48
81
  <Text
49
82
  style={{
@@ -68,6 +101,9 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
68
101
  ChildView && <ChildView />
69
102
  }
70
103
  </View>
71
- </TouchableOpacity>
104
+
105
+
106
+ </View>
107
+
72
108
  )
73
109
  }
package/src/index.ts CHANGED
@@ -149,10 +149,10 @@ import {
149
149
  ReactionsConfigurationInterface,
150
150
  ReactionsStyle,
151
151
  ReactionsStyleInterface,
152
- CometChatReactionsList,
153
- CometChatReactionsListInterface,
154
- ReactionsListConfiguration,
155
- ReactionsListConfigurationInterface,
152
+ CometChatReactionList,
153
+ CometChatReactionListInterface,
154
+ ReactionListConfiguration,
155
+ ReactionListConfigurationInterface,
156
156
  ReactionListStyle,
157
157
  ReactionListStyleInterface,
158
158
  CometChatQuickReactions,
@@ -699,10 +699,10 @@ export {
699
699
  ReactionsConfigurationInterface,
700
700
  ReactionsStyle,
701
701
  ReactionsStyleInterface,
702
- CometChatReactionsList,
703
- CometChatReactionsListInterface,
704
- ReactionsListConfiguration,
705
- ReactionsListConfigurationInterface,
702
+ CometChatReactionList,
703
+ CometChatReactionListInterface,
704
+ ReactionListConfiguration,
705
+ ReactionListConfigurationInterface,
706
706
  ReactionListStyle,
707
707
  ReactionListStyleInterface,
708
708
  CometChatQuickReactions,
@@ -1,4 +1,4 @@
1
- import React, { createContext, useState } from 'react';
1
+ import React, { createContext, useEffect, useState } from 'react';
2
2
  import { CometChatContextType } from './base/Types';
3
3
  import { CometChatTheme } from './resources/CometChatTheme';
4
4
  import { CometChatLocalize } from './resources/CometChatLocalize';
@@ -31,6 +31,10 @@ export const CometChatContextProvider = (props) => {
31
31
  setTheme(theme);
32
32
  }
33
33
 
34
+ useEffect(() => {
35
+ CometChatLocalize.init({})
36
+ }, [])
37
+
34
38
  return (
35
39
  <CometChatContext.Provider value={{theme, changeThemeMode, changeLocalise, applyTheme}}>
36
40
  {children}
@@ -51,6 +51,7 @@ export class CometChatUIKit {
51
51
  () => {
52
52
  CometChat.setSource("uikit-v4", Platform.OS, "react-native")
53
53
  ListenerInitializer.attachListeners();
54
+ this.enableExtensions();
54
55
  if (Platform.OS === "ios") {
55
56
  permissionUtilIOS.init().then(res => {
56
57
  if (res !== true) {
@@ -113,8 +114,6 @@ export class CometChatUIKit {
113
114
  let user = await CometChat.getLoggedinUser().catch((e) => Promise.reject(e))
114
115
  if (user == null) {
115
116
  Promise.reject(new CometChat.CometChatException({ code: "NOT_FOUND", message: "Login user not found" }));
116
- } else {
117
- this.enableExtensions()
118
117
  }
119
118
  return user;
120
119
  }
@@ -123,12 +122,10 @@ export class CometChatUIKit {
123
122
  if (CometChatUIKit.checkAuthSettings(Promise.reject)) null
124
123
  if (uid) {
125
124
  let user = await CometChat.login(uid, CometChatUIKit.uiKitSettings?.authKey).catch(e => Promise.reject(e));
126
- this.enableExtensions()
127
125
  return user;
128
126
  }
129
127
  if (authToken) {
130
128
  let user = await CometChat.login(authToken).catch(e => Promise.reject(e));
131
- this.enableExtensions()
132
129
  return user;
133
130
  }
134
131
  return Promise.reject(new CometChat.CometChatException({ code: "INVALID_LOGIN_ATTEMPT", message: "Provide uid or authToken" }));
@@ -145,10 +145,10 @@ import {
145
145
  ReactionsConfigurationInterface,
146
146
  ReactionsStyle,
147
147
  ReactionsStyleInterface,
148
- CometChatReactionsList,
149
- CometChatReactionsListInterface,
150
- ReactionsListConfiguration,
151
- ReactionsListConfigurationInterface,
148
+ CometChatReactionList,
149
+ CometChatReactionListInterface,
150
+ ReactionListConfiguration,
151
+ ReactionListConfigurationInterface,
152
152
  ReactionListStyle,
153
153
  ReactionListStyleInterface,
154
154
  CometChatQuickReactions,
@@ -344,10 +344,10 @@ export {
344
344
  ReactionsConfigurationInterface,
345
345
  ReactionsStyle,
346
346
  ReactionsStyleInterface,
347
- CometChatReactionsList,
348
- CometChatReactionsListInterface,
349
- ReactionsListConfiguration,
350
- ReactionsListConfigurationInterface,
347
+ CometChatReactionList,
348
+ CometChatReactionListInterface,
349
+ ReactionListConfiguration,
350
+ ReactionListConfigurationInterface,
351
351
  ReactionListStyle,
352
352
  ReactionListStyleInterface,
353
353
  CometChatQuickReactions,