@cometchat/chat-uikit-react-native 5.3.5 → 5.3.7
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.
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +18 -1
- package/ios/FileManager.m +14 -3
- package/ios/SoundPlayer.m +24 -1
- package/package.json +2 -1
- package/src/CometChatAIAssistantChatHistory/CometChatAIAssistantChatHistory.tsx +8 -3
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +14 -11
- package/src/CometChatConversations/CometChatConversations.tsx +89 -51
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +10 -11
- package/src/CometChatGroups/CometChatGroups.tsx +49 -42
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +10 -7
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +12 -10
- package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +4 -3
- package/src/CometChatMessageList/CometChatMessageList.tsx +398 -144
- package/src/CometChatMessageList/PERFORMANCE_ARCHITECTURE.md +478 -0
- package/src/CometChatMessageList/SEARCH_NAV_PERF_PLAN.md +613 -0
- package/src/CometChatMessageList/components/MessageOptionsSheet.tsx +4 -1
- package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +811 -0
- package/src/CometChatNotificationFeed/Skeleton.tsx +43 -0
- package/src/CometChatNotificationFeed/index.ts +19 -0
- package/src/CometChatNotificationFeed/style.ts +333 -0
- package/src/CometChatNotificationFeed/utils.ts +124 -0
- package/src/CometChatSearch/CometChatSearch.tsx +8 -6
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +4 -3
- package/src/CometChatUsers/CometChatUsers.tsx +56 -43
- package/src/calls/CallingExtensionDecorator.tsx +1 -1
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +3 -2
- package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +7 -6
- package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +2 -1
- package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +2 -1
- package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +4 -4
- package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +5 -3
- package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +1 -1
- package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +5 -5
- package/src/extensions/Polls/PollsBubble.tsx +1 -1
- package/src/extensions/Polls/PollsDecorator.tsx +1 -1
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -2
- package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +9 -5
- package/src/index.ts +7 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +48 -20
- package/src/shared/events/ListenerInitializer.ts +2 -1
- package/src/shared/framework/MessageDataSource.tsx +19 -15
- package/src/shared/helper/helperFunctions.ts +5 -4
- package/src/shared/icons/components/notification-empty.tsx +27 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +8 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +8 -1
- package/src/shared/services/stream-message.service.ts +0 -1
- package/src/shared/utils/CommonUtils.ts +1 -1
- package/src/shared/utils/MessageUtils.tsx +15 -13
- package/src/shared/utils/conversationUtils.ts +2 -2
- package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +2 -2
- package/src/shared/views/CometChatImageBubble/CometChatImageLoader.tsx +17 -5
- package/src/shared/views/CometChatList/CometChatList.tsx +11 -15
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +3 -3
- package/src/shared/views/CometChatReactions/CometChatReactions.tsx +2 -1
- package/src/shared/views/CometChatStreamMessageBubble/CometChatStreamMessageBubble.tsx +15 -4
- package/src/shared/views/CometChatSuggestionList/CometChatSuggestionList.tsx +3 -3
- package/src/shared/views/CometChatTextBubble/CometChatTextBubble.tsx +15 -1
- package/src/theme/default/default.ts +6 -0
- package/src/theme/provider.tsx +12 -12
- package/src/theme/type.ts +2 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Skeleton.tsx
|
|
3
|
+
*
|
|
4
|
+
* Simple loading indicator for CometChatNotificationFeed.
|
|
5
|
+
* Shows a centered ActivityIndicator with "Loading..." text
|
|
6
|
+
* while initial data is being fetched.
|
|
7
|
+
* Matches Figma: node-id=8257:16800 (Loading indicator)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { ActivityIndicator, Text, View } from "react-native";
|
|
12
|
+
import { useTheme } from "../theme";
|
|
13
|
+
import { getCometChatTranslation } from "../shared/resources/CometChatLocalizeNew/LocalizationManager";
|
|
14
|
+
|
|
15
|
+
const t = getCometChatTranslation();
|
|
16
|
+
|
|
17
|
+
export const Skeleton: React.FC = () => {
|
|
18
|
+
const theme = useTheme();
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<View
|
|
22
|
+
style={{
|
|
23
|
+
flex: 1,
|
|
24
|
+
justifyContent: "center",
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
backgroundColor: theme.color.background2,
|
|
27
|
+
}}
|
|
28
|
+
>
|
|
29
|
+
<View style={{ alignItems: "center", gap: 16 }}>
|
|
30
|
+
<ActivityIndicator size="large" color={theme.color.primary} />
|
|
31
|
+
<Text
|
|
32
|
+
style={{
|
|
33
|
+
color: theme.color.textSecondary,
|
|
34
|
+
...theme.typography.body.medium,
|
|
35
|
+
textAlign: "center",
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
{t("LOADING")}
|
|
39
|
+
</Text>
|
|
40
|
+
</View>
|
|
41
|
+
</View>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export { CometChatNotificationFeed } from "./CometChatNotificationFeed";
|
|
2
|
+
|
|
3
|
+
export { Skeleton } from "./Skeleton";
|
|
4
|
+
|
|
5
|
+
export { getNotificationFeedStyleLight, getNotificationFeedStyleDark } from "./style";
|
|
6
|
+
|
|
7
|
+
export { groupFeedItemsByTimestamp } from "./utils";
|
|
8
|
+
|
|
9
|
+
export type {
|
|
10
|
+
CometChatNotificationFeedInterface,
|
|
11
|
+
} from "./CometChatNotificationFeed";
|
|
12
|
+
|
|
13
|
+
export type {
|
|
14
|
+
NotificationFeedStyle,
|
|
15
|
+
} from "./style";
|
|
16
|
+
|
|
17
|
+
export type {
|
|
18
|
+
TimestampGroup,
|
|
19
|
+
} from "./utils";
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ColorValue,
|
|
3
|
+
ImageSourcePropType,
|
|
4
|
+
ImageStyle,
|
|
5
|
+
TextStyle,
|
|
6
|
+
ViewStyle,
|
|
7
|
+
} from "react-native";
|
|
8
|
+
import { deepMerge } from "../shared/helper/helperFunctions";
|
|
9
|
+
import { CometChatTheme } from "../theme/type";
|
|
10
|
+
import { DeepPartial } from "../shared/helper/types";
|
|
11
|
+
import { JSX } from "react";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Style type for the CometChatNotificationFeed component.
|
|
15
|
+
* Covers: container, header, filter chips, timestamp headers,
|
|
16
|
+
* card container, unread indicator, skeleton, and state views.
|
|
17
|
+
*/
|
|
18
|
+
export type NotificationFeedStyle = {
|
|
19
|
+
/** Root container */
|
|
20
|
+
containerStyle: ViewStyle;
|
|
21
|
+
|
|
22
|
+
/** Header */
|
|
23
|
+
headerContainerStyle: ViewStyle;
|
|
24
|
+
titleStyle: TextStyle;
|
|
25
|
+
backButtonIconStyle: ImageStyle;
|
|
26
|
+
backButtonIcon?: ImageSourcePropType | JSX.Element;
|
|
27
|
+
|
|
28
|
+
/** Filter Chips */
|
|
29
|
+
chipsContainerStyle: ViewStyle;
|
|
30
|
+
chipActiveStyle: {
|
|
31
|
+
containerStyle: ViewStyle;
|
|
32
|
+
textStyle: TextStyle;
|
|
33
|
+
};
|
|
34
|
+
chipInactiveStyle: {
|
|
35
|
+
containerStyle: ViewStyle;
|
|
36
|
+
textStyle: TextStyle;
|
|
37
|
+
};
|
|
38
|
+
chipBadgeStyle: {
|
|
39
|
+
containerStyle: ViewStyle;
|
|
40
|
+
textStyle: TextStyle;
|
|
41
|
+
};
|
|
42
|
+
chipInactiveBadgeStyle: {
|
|
43
|
+
containerStyle: ViewStyle;
|
|
44
|
+
textStyle: TextStyle;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** Timestamp Section Headers */
|
|
48
|
+
sectionHeaderStyle: {
|
|
49
|
+
containerStyle: ViewStyle;
|
|
50
|
+
textStyle: TextStyle;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** Per-item header: Category label + Timestamp */
|
|
54
|
+
itemHeaderStyle: {
|
|
55
|
+
containerStyle: ViewStyle;
|
|
56
|
+
categoryTextStyle: TextStyle;
|
|
57
|
+
timestampTextStyle: TextStyle;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
/** Feed Item Card Container */
|
|
61
|
+
cardContainerStyle: ViewStyle;
|
|
62
|
+
cardBorderColor: ColorValue;
|
|
63
|
+
cardBorderRadius: number;
|
|
64
|
+
cardBorderWidth: number;
|
|
65
|
+
|
|
66
|
+
/** Unread Indicator */
|
|
67
|
+
unreadIndicatorStyle: ViewStyle;
|
|
68
|
+
unreadIndicatorColor: ColorValue;
|
|
69
|
+
|
|
70
|
+
/** Skeleton / Loading */
|
|
71
|
+
skeletonStyle: {
|
|
72
|
+
linearGradientColors: [string, string];
|
|
73
|
+
shimmerBackgroundColor: ColorValue;
|
|
74
|
+
shimmerOpacity: number;
|
|
75
|
+
speed: number;
|
|
76
|
+
containerBackgroundColor: ColorValue;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** Empty State */
|
|
80
|
+
emptyStateStyle: {
|
|
81
|
+
containerStyle: ViewStyle;
|
|
82
|
+
titleStyle: TextStyle;
|
|
83
|
+
subTitleStyle: TextStyle;
|
|
84
|
+
icon?: ImageSourcePropType | JSX.Element;
|
|
85
|
+
iconStyle?: ImageStyle;
|
|
86
|
+
iconContainerStyle?: ViewStyle;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
/** Error State */
|
|
90
|
+
errorStateStyle: {
|
|
91
|
+
containerStyle: ViewStyle;
|
|
92
|
+
titleStyle: TextStyle;
|
|
93
|
+
subTitleStyle: TextStyle;
|
|
94
|
+
icon?: ImageSourcePropType | JSX.Element;
|
|
95
|
+
iconStyle?: ImageStyle;
|
|
96
|
+
iconContainerStyle?: ViewStyle;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/** Separator between items */
|
|
100
|
+
separatorStyle: ViewStyle;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const getNotificationFeedStyleLight = (
|
|
104
|
+
color: CometChatTheme["color"],
|
|
105
|
+
spacing: CometChatTheme["spacing"],
|
|
106
|
+
typography: CometChatTheme["typography"]
|
|
107
|
+
): DeepPartial<NotificationFeedStyle> => {
|
|
108
|
+
return {
|
|
109
|
+
containerStyle: {
|
|
110
|
+
flex: 1,
|
|
111
|
+
backgroundColor: color.background2,
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
headerContainerStyle: {
|
|
115
|
+
paddingHorizontal: spacing.padding.p4,
|
|
116
|
+
paddingVertical: spacing.padding.p3,
|
|
117
|
+
borderBottomColor: color.borderDefault,
|
|
118
|
+
borderBottomWidth: 1,
|
|
119
|
+
flexDirection: "row",
|
|
120
|
+
alignItems: "center",
|
|
121
|
+
},
|
|
122
|
+
titleStyle: {
|
|
123
|
+
color: color.textPrimary,
|
|
124
|
+
...typography.heading2.bold,
|
|
125
|
+
},
|
|
126
|
+
backButtonIconStyle: {
|
|
127
|
+
tintColor: color.iconPrimary,
|
|
128
|
+
height: spacing.spacing.s6,
|
|
129
|
+
width: spacing.spacing.s6,
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
chipsContainerStyle: {
|
|
133
|
+
paddingHorizontal: spacing.padding.p4,
|
|
134
|
+
paddingVertical: spacing.padding.p2,
|
|
135
|
+
flexDirection: "row",
|
|
136
|
+
gap: spacing.spacing.s2,
|
|
137
|
+
},
|
|
138
|
+
chipActiveStyle: {
|
|
139
|
+
containerStyle: {
|
|
140
|
+
backgroundColor: color.primary,
|
|
141
|
+
borderRadius: spacing.radius.max,
|
|
142
|
+
paddingHorizontal: spacing.padding.p3,
|
|
143
|
+
paddingVertical: 6,
|
|
144
|
+
flexDirection: "row",
|
|
145
|
+
alignItems: "center",
|
|
146
|
+
justifyContent: "center",
|
|
147
|
+
gap: spacing.spacing.s2,
|
|
148
|
+
},
|
|
149
|
+
textStyle: {
|
|
150
|
+
color: color.textWhite,
|
|
151
|
+
...typography.body.medium,
|
|
152
|
+
fontWeight: "600",
|
|
153
|
+
textAlign: "center",
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
chipInactiveStyle: {
|
|
157
|
+
containerStyle: {
|
|
158
|
+
backgroundColor: color.background2,
|
|
159
|
+
borderRadius: spacing.radius.max,
|
|
160
|
+
borderWidth: 1,
|
|
161
|
+
borderColor: color.borderDefault,
|
|
162
|
+
paddingHorizontal: spacing.padding.p3,
|
|
163
|
+
paddingVertical: 6,
|
|
164
|
+
flexDirection: "row",
|
|
165
|
+
alignItems: "center",
|
|
166
|
+
justifyContent: "center",
|
|
167
|
+
gap: spacing.spacing.s2,
|
|
168
|
+
},
|
|
169
|
+
textStyle: {
|
|
170
|
+
color: color.textTertiary,
|
|
171
|
+
...typography.body.medium,
|
|
172
|
+
fontWeight: "600",
|
|
173
|
+
textAlign: "center",
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
chipBadgeStyle: {
|
|
177
|
+
containerStyle: {
|
|
178
|
+
backgroundColor: color.extendedPrimary50,
|
|
179
|
+
borderRadius: spacing.radius.max,
|
|
180
|
+
borderWidth: 1,
|
|
181
|
+
borderColor: color.extendedPrimary200,
|
|
182
|
+
paddingHorizontal: spacing.spacing.s2,
|
|
183
|
+
paddingVertical: 2,
|
|
184
|
+
alignItems: "center",
|
|
185
|
+
justifyContent: "center",
|
|
186
|
+
},
|
|
187
|
+
textStyle: {
|
|
188
|
+
color: color.primary,
|
|
189
|
+
...typography.caption1.medium,
|
|
190
|
+
textAlign: "center",
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
chipInactiveBadgeStyle: {
|
|
194
|
+
containerStyle: {
|
|
195
|
+
backgroundColor: color.neutral700,
|
|
196
|
+
borderRadius: spacing.radius.max,
|
|
197
|
+
paddingHorizontal: spacing.spacing.s2,
|
|
198
|
+
paddingVertical: 2,
|
|
199
|
+
alignItems: "center",
|
|
200
|
+
justifyContent: "center",
|
|
201
|
+
},
|
|
202
|
+
textStyle: {
|
|
203
|
+
color: color.textWhite,
|
|
204
|
+
...typography.caption1.medium,
|
|
205
|
+
textAlign: "center",
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
sectionHeaderStyle: {
|
|
210
|
+
containerStyle: {
|
|
211
|
+
paddingHorizontal: spacing.padding.p4,
|
|
212
|
+
paddingVertical: spacing.padding.p2,
|
|
213
|
+
backgroundColor: color.background2,
|
|
214
|
+
flexDirection: "row",
|
|
215
|
+
alignItems: "center",
|
|
216
|
+
justifyContent: "space-between",
|
|
217
|
+
},
|
|
218
|
+
textStyle: {
|
|
219
|
+
color: color.textSecondary,
|
|
220
|
+
...typography.caption1.regular,
|
|
221
|
+
},
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
itemHeaderStyle: {
|
|
225
|
+
containerStyle: {
|
|
226
|
+
flexDirection: "row",
|
|
227
|
+
alignItems: "center",
|
|
228
|
+
justifyContent: "space-between",
|
|
229
|
+
paddingHorizontal: spacing.padding.p4,
|
|
230
|
+
paddingTop: spacing.padding.p3,
|
|
231
|
+
paddingBottom: spacing.padding.p1,
|
|
232
|
+
},
|
|
233
|
+
categoryTextStyle: {
|
|
234
|
+
color: color.textSecondary,
|
|
235
|
+
...typography.caption1.regular,
|
|
236
|
+
},
|
|
237
|
+
timestampTextStyle: {
|
|
238
|
+
color: color.textSecondary,
|
|
239
|
+
...typography.caption1.regular,
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
cardContainerStyle: {
|
|
244
|
+
marginHorizontal: spacing.margin.m4,
|
|
245
|
+
marginVertical: spacing.margin.m1,
|
|
246
|
+
borderRadius: spacing.radius.r3,
|
|
247
|
+
backgroundColor: color.background1,
|
|
248
|
+
overflow: "hidden",
|
|
249
|
+
},
|
|
250
|
+
cardBorderColor: color.borderLight,
|
|
251
|
+
cardBorderRadius: spacing.radius.r3,
|
|
252
|
+
cardBorderWidth: 1,
|
|
253
|
+
|
|
254
|
+
unreadIndicatorStyle: {
|
|
255
|
+
width: spacing.spacing.s2,
|
|
256
|
+
height: spacing.spacing.s2,
|
|
257
|
+
borderRadius: spacing.radius.max,
|
|
258
|
+
position: "absolute",
|
|
259
|
+
top: spacing.spacing.s3,
|
|
260
|
+
left: spacing.spacing.s2,
|
|
261
|
+
},
|
|
262
|
+
unreadIndicatorColor: color.primary,
|
|
263
|
+
|
|
264
|
+
skeletonStyle: {
|
|
265
|
+
linearGradientColors: ["#E8E8E8", "#F5F5F5"] as [string, string],
|
|
266
|
+
shimmerBackgroundColor: color.staticBlack,
|
|
267
|
+
shimmerOpacity: 0.01,
|
|
268
|
+
speed: 1,
|
|
269
|
+
containerBackgroundColor: color.background2,
|
|
270
|
+
},
|
|
271
|
+
|
|
272
|
+
emptyStateStyle: {
|
|
273
|
+
containerStyle: {
|
|
274
|
+
flex: 1,
|
|
275
|
+
justifyContent: "center",
|
|
276
|
+
alignItems: "center",
|
|
277
|
+
paddingHorizontal: spacing.padding.p4,
|
|
278
|
+
gap: spacing.spacing.s5,
|
|
279
|
+
},
|
|
280
|
+
titleStyle: {
|
|
281
|
+
color: color.textPrimary,
|
|
282
|
+
...typography.heading3.bold,
|
|
283
|
+
textAlign: "center",
|
|
284
|
+
},
|
|
285
|
+
subTitleStyle: {
|
|
286
|
+
color: color.textTertiary,
|
|
287
|
+
textAlign: "center",
|
|
288
|
+
...typography.body.regular,
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
|
|
292
|
+
errorStateStyle: {
|
|
293
|
+
containerStyle: {
|
|
294
|
+
flex: 1,
|
|
295
|
+
justifyContent: "center",
|
|
296
|
+
alignItems: "center",
|
|
297
|
+
paddingHorizontal: spacing.padding.p8,
|
|
298
|
+
},
|
|
299
|
+
titleStyle: {
|
|
300
|
+
color: color.textPrimary,
|
|
301
|
+
...typography.heading3.bold,
|
|
302
|
+
marginBottom: spacing.margin.m1,
|
|
303
|
+
},
|
|
304
|
+
subTitleStyle: {
|
|
305
|
+
color: color.textSecondary,
|
|
306
|
+
textAlign: "center",
|
|
307
|
+
...typography.body.regular,
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
|
+
|
|
311
|
+
separatorStyle: {
|
|
312
|
+
height: 1,
|
|
313
|
+
backgroundColor: color.borderLight,
|
|
314
|
+
marginHorizontal: spacing.margin.m4,
|
|
315
|
+
},
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
export const getNotificationFeedStyleDark = (
|
|
320
|
+
color: CometChatTheme["color"],
|
|
321
|
+
spacing: CometChatTheme["spacing"],
|
|
322
|
+
typography: CometChatTheme["typography"]
|
|
323
|
+
): DeepPartial<NotificationFeedStyle> => {
|
|
324
|
+
return deepMerge(getNotificationFeedStyleLight(color, spacing, typography), {
|
|
325
|
+
skeletonStyle: {
|
|
326
|
+
linearGradientColors: ["#383838", "#272727"] as [string, string],
|
|
327
|
+
shimmerBackgroundColor: color.staticWhite,
|
|
328
|
+
shimmerOpacity: 0.01,
|
|
329
|
+
speed: 1,
|
|
330
|
+
containerBackgroundColor: color.background2,
|
|
331
|
+
},
|
|
332
|
+
});
|
|
333
|
+
};
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Timestamp grouping utility for CometChatNotificationFeed.
|
|
3
|
+
* Groups NotificationFeedItems by sentAt into sections for SectionList.
|
|
4
|
+
*
|
|
5
|
+
* Groups: "Today", "Yesterday", day name (Mon–Sun) for this week, localized date for older.
|
|
6
|
+
* Items within each group ordered newest-first.
|
|
7
|
+
* Groups ordered newest-first.
|
|
8
|
+
* Total count invariant: no items lost or duplicated.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Represents a single timestamp group (section) for SectionList */
|
|
12
|
+
export interface TimestampGroup<T> {
|
|
13
|
+
title: string;
|
|
14
|
+
data: T[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** Day names for "this week" grouping */
|
|
18
|
+
const DAY_NAMES = [
|
|
19
|
+
"Sunday",
|
|
20
|
+
"Monday",
|
|
21
|
+
"Tuesday",
|
|
22
|
+
"Wednesday",
|
|
23
|
+
"Thursday",
|
|
24
|
+
"Friday",
|
|
25
|
+
"Saturday",
|
|
26
|
+
] as const;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Returns the start of a given day (midnight) for comparison purposes.
|
|
30
|
+
*/
|
|
31
|
+
const getStartOfDay = (date: Date): number => {
|
|
32
|
+
const d = new Date(date);
|
|
33
|
+
d.setHours(0, 0, 0, 0);
|
|
34
|
+
return d.getTime();
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Determines the group label for a given timestamp.
|
|
39
|
+
*
|
|
40
|
+
* @param sentAt - Unix timestamp in seconds
|
|
41
|
+
* @param now - Current Date (injected for testability)
|
|
42
|
+
* @returns Group label string
|
|
43
|
+
*/
|
|
44
|
+
const getGroupLabel = (sentAt: number, now: Date): string => {
|
|
45
|
+
const itemDate = new Date(sentAt * 1000);
|
|
46
|
+
const todayStart = getStartOfDay(now);
|
|
47
|
+
const itemDayStart = getStartOfDay(itemDate);
|
|
48
|
+
|
|
49
|
+
const diffMs = todayStart - itemDayStart;
|
|
50
|
+
const diffDays = Math.floor(diffMs / (24 * 60 * 60 * 1000));
|
|
51
|
+
|
|
52
|
+
if (diffDays === 0) {
|
|
53
|
+
return "Today";
|
|
54
|
+
}
|
|
55
|
+
if (diffDays === 1) {
|
|
56
|
+
return "Yesterday";
|
|
57
|
+
}
|
|
58
|
+
// Within this week (2-6 days ago) — show day name
|
|
59
|
+
if (diffDays >= 2 && diffDays <= 6) {
|
|
60
|
+
return DAY_NAMES[itemDate.getDay()];
|
|
61
|
+
}
|
|
62
|
+
// Older — show localized date
|
|
63
|
+
return itemDate.toLocaleDateString(undefined, {
|
|
64
|
+
month: "short",
|
|
65
|
+
day: "numeric",
|
|
66
|
+
year: "numeric",
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Groups feed items by their sentAt timestamp into sections.
|
|
72
|
+
*
|
|
73
|
+
* Pure function — no side effects, memoizable.
|
|
74
|
+
* Correctness guarantee: total items across all groups === input count.
|
|
75
|
+
*
|
|
76
|
+
* @param items - Array of objects with a getSentAt() method returning unix timestamp (seconds)
|
|
77
|
+
* @param now - Optional current date (defaults to new Date(), injectable for testing)
|
|
78
|
+
* @returns Array of TimestampGroup sections, ordered newest-first
|
|
79
|
+
*/
|
|
80
|
+
export const groupFeedItemsByTimestamp = <T extends { sentAt: number }>(
|
|
81
|
+
items: T[],
|
|
82
|
+
now: Date = new Date()
|
|
83
|
+
): TimestampGroup<T>[] => {
|
|
84
|
+
if (items.length === 0) return [];
|
|
85
|
+
|
|
86
|
+
// Group items by label, preserving insertion order (newest-first assumed from input)
|
|
87
|
+
const groupMap = new Map<string, T[]>();
|
|
88
|
+
// Track group order by the max sentAt in each group (for sorting)
|
|
89
|
+
const groupMaxTimestamp = new Map<string, number>();
|
|
90
|
+
|
|
91
|
+
for (const item of items) {
|
|
92
|
+
const sentAt = item.sentAt;
|
|
93
|
+
const label = getGroupLabel(sentAt, now);
|
|
94
|
+
|
|
95
|
+
const existing = groupMap.get(label);
|
|
96
|
+
if (existing) {
|
|
97
|
+
existing.push(item);
|
|
98
|
+
} else {
|
|
99
|
+
groupMap.set(label, [item]);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const currentMax = groupMaxTimestamp.get(label) ?? 0;
|
|
103
|
+
if (sentAt > currentMax) {
|
|
104
|
+
groupMaxTimestamp.set(label, sentAt);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Convert to array and sort groups newest-first
|
|
109
|
+
const groups: TimestampGroup<T>[] = [];
|
|
110
|
+
for (const [title, data] of groupMap) {
|
|
111
|
+
// Sort items within group newest-first
|
|
112
|
+
data.sort((a, b) => b.sentAt - a.sentAt);
|
|
113
|
+
groups.push({ title, data });
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// Sort groups by their newest item (descending)
|
|
117
|
+
groups.sort((a, b) => {
|
|
118
|
+
const aMax = groupMaxTimestamp.get(a.title) ?? 0;
|
|
119
|
+
const bMax = groupMaxTimestamp.get(b.title) ?? 0;
|
|
120
|
+
return bMax - aMax;
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return groups;
|
|
124
|
+
};
|
|
@@ -1016,8 +1016,9 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
1016
1016
|
return;
|
|
1017
1017
|
}
|
|
1018
1018
|
|
|
1019
|
-
|
|
1020
|
-
|
|
1019
|
+
const request = buildConversationsRequest();
|
|
1020
|
+
conversationRequestRef.current = request;
|
|
1021
|
+
const conversations = await request.fetchNext();
|
|
1021
1022
|
|
|
1022
1023
|
if (conversations.length > 0) {
|
|
1023
1024
|
const limit = (guid || uid || searchState.activeFilters.length > 0) ? 30 : 3;
|
|
@@ -1145,8 +1146,9 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
1145
1146
|
return;
|
|
1146
1147
|
}
|
|
1147
1148
|
|
|
1148
|
-
|
|
1149
|
-
|
|
1149
|
+
const request = buildMessagesRequest();
|
|
1150
|
+
messageRequestRef.current = request;
|
|
1151
|
+
const messages = await request.fetchPrevious();
|
|
1150
1152
|
|
|
1151
1153
|
if (messages.length > 0) {
|
|
1152
1154
|
const reversedList = messages.reverse();
|
|
@@ -1811,7 +1813,7 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
1811
1813
|
(message.getType() === 'image' || message.getType() === 'video') && mergedStyles.messageItemStyle?.textContainerStyle
|
|
1812
1814
|
]}>
|
|
1813
1815
|
<Text style={mergedStyles.messageItemStyle?.titleStyle} numberOfLines={1}>
|
|
1814
|
-
{message.getSender()
|
|
1816
|
+
{message.getSender()?.getName()}
|
|
1815
1817
|
</Text>
|
|
1816
1818
|
<Text style={mergedStyles.messageItemStyle?.subtitleStyle} numberOfLines={2}>
|
|
1817
1819
|
{(() => {
|
|
@@ -2083,7 +2085,7 @@ export const CometChatSearch: React.FC<CometChatSearchProps> = ({
|
|
|
2083
2085
|
(message.getType() === 'image' || message.getType() === 'video') && mergedStyles.messageItemStyle?.textContainerStyle
|
|
2084
2086
|
]}>
|
|
2085
2087
|
<Text style={mergedStyles.messageItemStyle?.titleStyle} numberOfLines={1}>
|
|
2086
|
-
{message.getSender()
|
|
2088
|
+
{message.getSender()?.getName()}
|
|
2087
2089
|
</Text>
|
|
2088
2090
|
<Text style={mergedStyles.messageItemStyle?.subtitleStyle} numberOfLines={2}>
|
|
2089
2091
|
{(() => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
let __listenerIdCounter = 0;
|
|
1
2
|
import React, { useEffect, useState, useMemo, JSX } from "react";
|
|
2
3
|
import { ScrollView, Text, View } from "react-native";
|
|
3
4
|
import {
|
|
@@ -26,7 +27,7 @@ import { urlPattern } from "../shared/constants/UIKitConstants";
|
|
|
26
27
|
/**
|
|
27
28
|
* Unique UI event identifier for CometChatUIEventHandler.
|
|
28
29
|
*/
|
|
29
|
-
const uiEventId = "ccUiEvent" +
|
|
30
|
+
const uiEventId = "ccUiEvent" + Date.now() + "_" + (++__listenerIdCounter);
|
|
30
31
|
|
|
31
32
|
/**
|
|
32
33
|
* Interface for the props of CometChatThreadHeader component.
|
|
@@ -121,7 +122,7 @@ export const CometChatThreadHeader = (props: CometChatThreadHeaderInterface): JS
|
|
|
121
122
|
|
|
122
123
|
const theme = useTheme();
|
|
123
124
|
const { t } = useCometChatTranslation();
|
|
124
|
-
const style = deepMerge(theme.threadHeaderStyles, props.style ?? {});
|
|
125
|
+
const style = useMemo(() => deepMerge(theme.threadHeaderStyles, props.style ?? {}), [theme, props.style]);
|
|
125
126
|
|
|
126
127
|
/**
|
|
127
128
|
* Checks if an updated message belongs to the same thread as the current message.
|
|
@@ -270,7 +271,7 @@ export const CometChatThreadHeader = (props: CometChatThreadHeaderInterface): JS
|
|
|
270
271
|
}),
|
|
271
272
|
alignment: alignment
|
|
272
273
|
? alignment
|
|
273
|
-
: message.getSender()
|
|
274
|
+
: message.getSender()?.getUid() === CometChatUIKit.loggedInUser?.getUid()
|
|
274
275
|
? "right"
|
|
275
276
|
: "left",
|
|
276
277
|
theme: mergedTheme,
|