@cometchat/chat-uikit-react-native 5.3.4 → 5.3.6
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/package.json +2 -1
- package/src/CometChatConversations/CometChatConversations.tsx +107 -18
- package/src/CometChatMessageList/CometChatMessageList.tsx +24 -5
- 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/extensions/LinkPreview/LinkPreviewBubble.tsx +22 -18
- package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +1 -1
- package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +5 -1
- package/src/index.ts +7 -0
- 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/utils/MessageReceiptUtils.ts +0 -1
- package/src/shared/views/CometChatInlineAudioRecorder/useAudioRecorder.ts +53 -21
- package/src/shared/views/CometChatList/CometChatList.tsx +26 -15
- package/src/theme/default/default.ts +6 -0
- 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
|
+
};
|
|
@@ -56,9 +56,11 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
|
|
|
56
56
|
|
|
57
57
|
const _style = style;
|
|
58
58
|
|
|
59
|
-
const [imageSource, setImageSource] = useState(
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
const [imageSource, setImageSource] = useState(
|
|
60
|
+
image
|
|
61
|
+
? { uri: image.startsWith("https:") ? image : `https:${image.split("http:")[1]}` }
|
|
62
|
+
: undefined
|
|
63
|
+
);
|
|
62
64
|
|
|
63
65
|
const [imageHeight, setImageHeight] = useState<DimensionValue>();
|
|
64
66
|
const [imageWidth, setImageWidth] = useState<DimensionValue>();
|
|
@@ -145,20 +147,22 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
|
|
|
145
147
|
onTouchEnd={handleTouchEnd}
|
|
146
148
|
onTouchMove={onTouchMove}
|
|
147
149
|
>
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
150
|
+
{imageSource ? (
|
|
151
|
+
<View
|
|
152
|
+
style={style?.headerImageContainerStyle}
|
|
153
|
+
onTouchStart={handleTouchStart}
|
|
154
|
+
onTouchEnd={handleTouchEnd}
|
|
155
|
+
onTouchMove={onTouchMove}
|
|
156
|
+
>
|
|
157
|
+
<Image
|
|
158
|
+
source={imageSource}
|
|
159
|
+
style={[{ height: imageHeight, width: imageWidth }, style?.headerImageStyle]}
|
|
160
|
+
onError={(err) => {
|
|
161
|
+
setImageSource(DefaultLinkPreview);
|
|
162
|
+
}}
|
|
163
|
+
/>
|
|
164
|
+
</View>
|
|
165
|
+
) : null}
|
|
162
166
|
|
|
163
167
|
<View style={style?.bodyStyle?.containerStyle}>
|
|
164
168
|
<View style={{ flexDirection: "row" }}>
|
|
@@ -168,7 +172,7 @@ export const LinkPreviewBubble = (props: LinkPreviewBubbleInterface) => {
|
|
|
168
172
|
</Text>
|
|
169
173
|
</View>
|
|
170
174
|
|
|
171
|
-
{!faviconError && (
|
|
175
|
+
{!imageSource && !faviconError && (
|
|
172
176
|
<View style={style?.bodyStyle?.faviconContainerStyle}>
|
|
173
177
|
<Image
|
|
174
178
|
source={faviconSource}
|
|
@@ -69,7 +69,7 @@ export class LinkPreviewExtensionDecorator extends DataSourceDecorator {
|
|
|
69
69
|
? theme.messageListStyles?.outgoingMessageBubbleStyles?.linkPreviewBubbleStyles
|
|
70
70
|
: theme.messageListStyles?.incomingMessageBubbleStyles?.linkPreviewBubbleStyles;
|
|
71
71
|
const { image, favicon, title, url, description } = linkData.links[0];
|
|
72
|
-
const img = image.length === 0
|
|
72
|
+
const img = image.length === 0 || image === favicon ? "" : image;
|
|
73
73
|
return (
|
|
74
74
|
<LinkPreviewBubble
|
|
75
75
|
link={url}
|
|
@@ -48,7 +48,11 @@ export class ThumbnailGenerationExtensionDecorator extends DataSourceDecorator {
|
|
|
48
48
|
let image: { uri: string } = { uri: "" };
|
|
49
49
|
const thumbnailData = getExtensionData(message, ExtensionConstants.thumbnailGeneration);
|
|
50
50
|
if (thumbnailData == undefined) {
|
|
51
|
-
|
|
51
|
+
if (message.getType() === "image") {
|
|
52
|
+
const data = message?.getData() as any;
|
|
53
|
+
const fallbackUrl = data?.url ?? data?.attachments?.[0]?.url ?? "";
|
|
54
|
+
image = { uri: fallbackUrl };
|
|
55
|
+
}
|
|
52
56
|
} else {
|
|
53
57
|
const attachmentData = thumbnailData["attachments"];
|
|
54
58
|
if (attachmentData.length) {
|
package/src/index.ts
CHANGED
|
@@ -111,6 +111,11 @@ import {
|
|
|
111
111
|
ConversationInterface
|
|
112
112
|
} from "./CometChatConversations";
|
|
113
113
|
|
|
114
|
+
import {
|
|
115
|
+
CometChatNotificationFeed,
|
|
116
|
+
CometChatNotificationFeedInterface,
|
|
117
|
+
} from "./CometChatNotificationFeed";
|
|
118
|
+
|
|
114
119
|
import { CometChatGroupMembers, CometChatGroupMembersInterface } from "./CometChatGroupMembers";
|
|
115
120
|
|
|
116
121
|
import {
|
|
@@ -213,6 +218,7 @@ export {
|
|
|
213
218
|
//
|
|
214
219
|
CometChatConversationUtils,
|
|
215
220
|
CometChatConversations,
|
|
221
|
+
CometChatNotificationFeed,
|
|
216
222
|
CometChatCreatePoll,
|
|
217
223
|
CometChatDate,
|
|
218
224
|
/* Reactions */
|
|
@@ -361,6 +367,7 @@ export type {
|
|
|
361
367
|
CometChatUsersInterface,
|
|
362
368
|
CometChatVideoBubbleInterface,
|
|
363
369
|
ConversationInterface,
|
|
370
|
+
CometChatNotificationFeedInterface,
|
|
364
371
|
LinkPreviewBubbleInterface,
|
|
365
372
|
PollsConfigurationInterface,
|
|
366
373
|
RecorderState,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Svg, { Path } from "react-native-svg";
|
|
2
|
+
import type { SvgProps } from "react-native-svg";
|
|
3
|
+
|
|
4
|
+
const SvgComponent = ({ height, width, color }: SvgProps) => (
|
|
5
|
+
<Svg width={width ?? 100} height={height ?? 97} fill="none" viewBox="0 0 100 97">
|
|
6
|
+
<Path
|
|
7
|
+
fillRule="evenodd"
|
|
8
|
+
clipRule="evenodd"
|
|
9
|
+
d="M80.668 29.5988C79.9126 28.5923 78.7274 28 77.4689 28H22.5311C21.2726 28 20.0874 28.5923 19.332 29.5988L5.84197 47.5713C5.29692 48.2974 5.01514 49.1874 5.04293 50.0949L6.07625 83.8354C6.14241 85.9959 7.91291 87.713 10.0744 87.713H89.9265C92.088 87.713 93.8585 85.9958 93.9247 83.8353L94.9571 50.0949C94.9849 49.1874 94.7031 48.2974 94.1581 47.5713L80.668 29.5988ZM63.361 48.693C61.1519 48.693 59.4382 50.5634 58.5213 52.5732C57.0466 55.8059 53.786 58.052 50.001 58.052C46.2153 58.052 42.9545 55.8059 41.4797 52.5732C40.5628 50.5634 38.8491 48.693 36.64 48.693H18.978C15.6811 48.693 13.7998 44.9285 15.779 42.2917L21.495 34.6767C22.2504 33.6703 23.4355 33.078 24.694 33.078H32.851H67.168H75.325C76.5835 33.078 77.7686 33.6703 78.524 34.6767L84.24 42.2917C86.2192 44.9285 84.3379 48.693 81.041 48.693H63.361Z"
|
|
10
|
+
fill={color as string ?? "#A4A7AE"}
|
|
11
|
+
/>
|
|
12
|
+
<Path
|
|
13
|
+
d="M49 1C49 0.447716 49.4477 0 50 0C50.5523 0 51 0.447715 51 1V23C51 23.5523 50.5523 24 50 24C49.4477 24 49 23.5523 49 23V1Z"
|
|
14
|
+
fill={color as string ?? "#A4A7AE"}
|
|
15
|
+
/>
|
|
16
|
+
<Path
|
|
17
|
+
d="M19.7071 8.12129C19.3166 7.73077 19.3166 7.0976 19.7071 6.70708C20.0976 6.31655 20.7308 6.31655 21.1213 6.70708L36.6777 22.2634C37.0682 22.654 37.0682 23.2871 36.6777 23.6776C36.2871 24.0682 35.654 24.0682 35.2635 23.6776L19.7071 8.12129Z"
|
|
18
|
+
fill={color as string ?? "#A4A7AE"}
|
|
19
|
+
/>
|
|
20
|
+
<Path
|
|
21
|
+
d="M80.6777 8.12129C81.0682 7.73077 81.0682 7.0976 80.6777 6.70708C80.2871 6.31655 79.654 6.31655 79.2634 6.70708L63.7071 22.2634C63.3166 22.654 63.3166 23.2871 63.7071 23.6776C64.0976 24.0682 64.7308 24.0682 65.1213 23.6776L80.6777 8.12129Z"
|
|
22
|
+
fill={color as string ?? "#A4A7AE"}
|
|
23
|
+
/>
|
|
24
|
+
</Svg>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export default SvgComponent;
|
|
@@ -490,5 +490,12 @@
|
|
|
490
490
|
"LINK_TEXT": "Linktext",
|
|
491
491
|
"URL": "URL",
|
|
492
492
|
"INSERT": "Einfügen",
|
|
493
|
-
"GROUP_NO_LONGER_MEMBER": "Sie können keine Nachricht an diese Gruppe senden, da Sie kein Mitglied mehr sind."
|
|
493
|
+
"GROUP_NO_LONGER_MEMBER": "Sie können keine Nachricht an diese Gruppe senden, da Sie kein Mitglied mehr sind.",
|
|
494
|
+
"NOTIFICATION_FEED_EMPTY_TITLE": "Noch nichts hier",
|
|
495
|
+
"NOTIFICATION_FEED_EMPTY_SUBTITLE": "Neue Aktivitäten werden hier angezeigt, sobald sie verfügbar sind.",
|
|
496
|
+
"NOTIFICATION_FEED_ERROR_TITLE": "Etwas ist schiefgelaufen",
|
|
497
|
+
"NOTIFICATION_FEED_ERROR_SUBTITLE": "Benachrichtigungen konnten nicht geladen werden. Bitte versuchen Sie es erneut.",
|
|
498
|
+
"NOTIFICATION_FEED_LOADING_MORE": "Laden...",
|
|
499
|
+
"NOTIFICATION_FEED_LOAD_MORE_ERROR": "Weitere konnten nicht geladen werden",
|
|
500
|
+
"NOTIFICATION_FEED_TAP_TO_RETRY": "Zum Wiederholen tippen"
|
|
494
501
|
}
|
|
@@ -510,5 +510,12 @@
|
|
|
510
510
|
"MESSAGE_REPORTED": "Message reported",
|
|
511
511
|
"MARK_AS_UNREAD": "Mark Unread",
|
|
512
512
|
"NEW": "New",
|
|
513
|
-
"GROUP_NO_LONGER_MEMBER": "You can't send message to this group because you're no longer a member."
|
|
513
|
+
"GROUP_NO_LONGER_MEMBER": "You can't send message to this group because you're no longer a member.",
|
|
514
|
+
"NOTIFICATION_FEED_EMPTY_TITLE": "Nothing here yet",
|
|
515
|
+
"NOTIFICATION_FEED_EMPTY_SUBTITLE": "New activity will appear here when available.",
|
|
516
|
+
"NOTIFICATION_FEED_ERROR_TITLE": "Something went wrong",
|
|
517
|
+
"NOTIFICATION_FEED_ERROR_SUBTITLE": "Unable to load notifications. Please try again.",
|
|
518
|
+
"NOTIFICATION_FEED_LOADING_MORE": "Loading...",
|
|
519
|
+
"NOTIFICATION_FEED_LOAD_MORE_ERROR": "Couldn't load more",
|
|
520
|
+
"NOTIFICATION_FEED_TAP_TO_RETRY": "Tap to retry"
|
|
514
521
|
}
|