@cometchat/chat-uikit-react-native 5.5.3 → 5.6.0
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/build.gradle +5 -0
- package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +78 -3
- package/android/src/main/java/com/reactnativecometchatuikit/RichTextEditorView.kt +47 -4
- package/android/src/main/java/com/reactnativecometchatuikit/SafeFileName.java +78 -0
- package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +209 -119
- package/ios/CCLocalFileGuard.h +19 -0
- package/ios/CCLocalFileGuard.m +34 -0
- package/ios/FileManager.m +70 -6
- package/ios/RichTextEditorView.swift +96 -1
- package/ios/SoundPlayer.m +152 -6
- package/ios/VideoManager.m +1 -1
- package/package.json +18 -3
- package/react-native-cometchat-ui-kit.podspec +1 -1
- package/src/CometChatCompactMessageComposer/CometChatCompactMessageComposer.tsx +167 -79
- package/src/CometChatConversations/CometChatConversations.tsx +240 -117
- package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +4 -0
- package/src/CometChatGroups/CometChatGroups.tsx +61 -52
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +173 -85
- package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +7 -3
- package/src/CometChatMessageHeader/listners.ts +76 -56
- package/src/CometChatMessageList/CometChatMessageList.tsx +1423 -205
- package/src/CometChatNotificationFeed/CometChatNotificationFeed.tsx +71 -7
- package/src/CometChatPinnedMessages/CometChatPinnedMessages.tsx +74 -2
- package/src/CometChatSavedMessages/CometChatSavedMessages.tsx +69 -4
- package/src/CometChatSearch/CometChatSearch.tsx +353 -101
- package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +23 -1
- package/src/CometChatUsers/CometChatUsers.tsx +2 -0
- package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +19 -0
- package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +48 -47
- package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -0
- package/src/index.ts +6 -0
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +85 -2
- package/src/shared/CometChatUiKit/UIKitSettings.ts +20 -0
- package/src/shared/events/CometChatUIEventHandler/Listener.ts +10 -0
- package/src/shared/events/index.ts +4 -0
- package/src/shared/events/offline.ts +28 -0
- package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +5 -3
- package/src/shared/framework/MessageDataSource.tsx +34 -14
- package/src/shared/index.ts +2 -0
- package/src/shared/offline/OfflineHub.ts +651 -0
- package/src/shared/offline/OfflineMediaBubble.tsx +49 -0
- package/src/shared/offline/OfflineViews.tsx +218 -0
- package/src/shared/offline/conversationPins.ts +137 -0
- package/src/shared/offline/conversations.ts +325 -0
- package/src/shared/offline/frameProbe.ts +24 -0
- package/src/shared/offline/gate.ts +94 -0
- package/src/shared/offline/groupActions.ts +81 -0
- package/src/shared/offline/identity.ts +162 -0
- package/src/shared/offline/index.ts +76 -0
- package/src/shared/offline/media.ts +247 -0
- package/src/shared/offline/notices.ts +90 -0
- package/src/shared/offline/reconcile.ts +296 -0
- package/src/shared/offline/searchOutcome.ts +62 -0
- package/src/shared/offline/send.ts +430 -0
- package/src/shared/offline/stateContract.ts +85 -0
- package/src/shared/offline/threadReplies.ts +125 -0
- package/src/shared/offline/twoPhase.ts +372 -0
- package/src/shared/offline/unsentActions.ts +168 -0
- package/src/shared/offline/useOfflineMediaUri.ts +87 -0
- package/src/shared/offline/useOfflineReconnect.ts +25 -0
- package/src/shared/offline/useOfflineSessionEnded.ts +22 -0
- package/src/shared/offline/useOfflineUploadTray.ts +76 -0
- package/src/shared/offline/usePresenceHidden.ts +33 -0
- package/src/shared/resources/CometChatLocalizeNew/resources/de/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/en/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/es/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/fr/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hi/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/hu/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/it/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ja/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ko/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/lt/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ms/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/nl/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/pt/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/ru/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/sv/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/tr/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh/translation.json +24 -1
- package/src/shared/resources/CometChatLocalizeNew/resources/zh-tw/translation.json +24 -1
- package/src/shared/services/UploadQueueService.ts +106 -1
- package/src/shared/utils/MessageReceiptUtils.ts +8 -0
- package/src/shared/utils/SavedMessagesHelper.ts +18 -1
- package/src/shared/utils/catchUpCursor.ts +36 -0
- package/src/shared/utils/failedMessageRetry.ts +73 -0
- package/src/shared/utils/messageIdentity.ts +38 -0
- package/src/shared/views/CometChatAttachmentViewer/CometChatAttachmentViewer.tsx +34 -5
- package/src/shared/views/CometChatAudiosBubble/CometChatAudiosBubble.tsx +10 -2
- package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +13 -27
- package/src/shared/views/CometChatFilesBubble/CometChatFilesBubble.tsx +60 -11
- package/src/shared/views/CometChatImagesBubble/CometChatImagesBubble.tsx +27 -2
- package/src/shared/views/CometChatList/CometChatList.tsx +468 -7
- package/src/shared/views/CometChatMediaViewer/CometChatMediaViewer.tsx +27 -5
- package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +1 -0
- package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +56 -10
- package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +4 -0
- package/src/shared/views/CometChatVideosBubble/CometChatVideosBubble.tsx +36 -2
- package/src/shared/views/CometChatVoiceNoteBubble/CometChatVoiceNoteBubble.tsx +24 -12
- package/src/theme/type.ts +17 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one send helper for every own send (README §3.4, UIK-SEND-10): composer and compact
|
|
3
|
+
* composer text, media, voice notes and attachment batches, and the `CometChatUIKit.send*`
|
|
4
|
+
* statics (which stickers, call buttons and extensions go through).
|
|
5
|
+
*
|
|
6
|
+
* {@link routeSend} reads the gate once, when the user sends. Offline OFF: it runs the call
|
|
7
|
+
* site's existing code unchanged, so each path keeps its own OFF payload (composer text replaces
|
|
8
|
+
* metadata with `{error:true}`, statics merge into `data.metaData`, `ccReplyToMessage`,
|
|
9
|
+
* `onSendButtonPress`). Offline ON: it sends with the SDK's three-phase `MessageSentListener`
|
|
10
|
+
* (the form the SDK queues) and reports each transition to the {@link OfflineHub}, which updates
|
|
11
|
+
* the row and emits the public events exactly once.
|
|
12
|
+
*
|
|
13
|
+
* UI state never waits on the SDK's Promise: offline it rejects for a queued send, and a send
|
|
14
|
+
* that was never attempted may never settle on logout (SDK known issue, A3). The kit settles such
|
|
15
|
+
* a send itself when the session ends or the cache is reset, once and quietly, as Android does
|
|
16
|
+
* (`OfflineSend.rejectOpenCalls`): see {@link isQuietRejection}.
|
|
17
|
+
*
|
|
18
|
+
* @internal
|
|
19
|
+
*/
|
|
20
|
+
import { CometChatUIEventHandler } from "../events/CometChatUIEventHandler/CometChatUIEventHandler";
|
|
21
|
+
import { offlineSdk, isOfflineOn, sdkConnected } from "./gate";
|
|
22
|
+
import { localIdOf, OfflineFailureReason, OfflineMessageStatus, statusOf } from "./identity";
|
|
23
|
+
import { OfflineHub } from "./OfflineHub";
|
|
24
|
+
import { DISCARD_ERROR, errorCodeOf } from "./unsentActions";
|
|
25
|
+
|
|
26
|
+
export type OfflineSendKind = "text" | "media" | "custom" | "interactive";
|
|
27
|
+
|
|
28
|
+
export interface OfflineSendResult {
|
|
29
|
+
/** `sending` = accepted and queued: the row keeps the clock; not a failure. */
|
|
30
|
+
state: "sent" | "sending" | "failed";
|
|
31
|
+
message: any;
|
|
32
|
+
error?: unknown;
|
|
33
|
+
reason?: string;
|
|
34
|
+
/** Failed without entering the outbox; Retry is a fresh send. */
|
|
35
|
+
direct?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* Failed only because the session ended (logout, user switch) or the cache was reset: nothing to
|
|
38
|
+
* show or report, as on Android ({@link isQuietRejection}).
|
|
39
|
+
*/
|
|
40
|
+
quiet?: boolean;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface OfflineSendHooks {
|
|
44
|
+
/** The message reached the server (also after it was queued). */
|
|
45
|
+
onSent?(message: any): void;
|
|
46
|
+
/**
|
|
47
|
+
* A final failure or a direct error (never for a queued send). `quiet` is true when the send
|
|
48
|
+
* ended only because the session ended or the cache was reset: the app is not told of an error.
|
|
49
|
+
*/
|
|
50
|
+
onFailed?(error: unknown, message: any, reason: string, direct: boolean, quiet?: boolean): void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* True for a rejection the kit must never surface as an error (Android `isQuietRejection`): the
|
|
55
|
+
* session ended (logout or user switch), the cache was reset, or the unsent message was removed.
|
|
56
|
+
*/
|
|
57
|
+
export function isQuietRejection(error: unknown): boolean {
|
|
58
|
+
const code = errorCodeOf(error);
|
|
59
|
+
return code === DISCARD_ERROR.discarded || code === OfflineFailureReason.discarded || code === DISCARD_ERROR.notLoggedIn;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** An `onFailed` hook that hands the app's `onError` every failure except a quiet one. */
|
|
63
|
+
export function quietAwareOnError(onError?: (error: any) => void): OfflineSendHooks["onFailed"] {
|
|
64
|
+
if (!onError) return undefined;
|
|
65
|
+
return (error, _message, _reason, _direct, quiet) => {
|
|
66
|
+
if (!quiet && !isQuietRejection(error)) onError(error);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The rejection of a send that ended with the session or the cache (Android `ERROR_DISCARDED`). */
|
|
71
|
+
function quietDiscardError(why: string): Error {
|
|
72
|
+
return Object.assign(new Error(why), {
|
|
73
|
+
code: DISCARD_ERROR.discarded,
|
|
74
|
+
reason: OfflineFailureReason.discarded,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Which SDK send a message goes through. */
|
|
79
|
+
export function sendKindOf(message: any): OfflineSendKind {
|
|
80
|
+
const category = message?.getCategory?.();
|
|
81
|
+
if (category === "custom") return "custom";
|
|
82
|
+
if (category === "interactive") return "interactive";
|
|
83
|
+
return message?.getType?.() === "text" ? "text" : "media";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const KNOWN_REASONS = Object.values(OfflineFailureReason) as string[];
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* SDK error codes that stand for a `MessageFailureReason`. The outbox refuses a send it cannot
|
|
90
|
+
* admit with Android's one code, `ERROR_PENDING_QUEUE_LIMIT` (UIK-SEND-03), and names the reason
|
|
91
|
+
* (`QUEUE_FULL`, `QUEUE_OVERFLOW`, `BYTE_OVERFLOW`) beside it. A reason that rides along always
|
|
92
|
+
* wins; the code alone means a full queue.
|
|
93
|
+
*/
|
|
94
|
+
const REASON_BY_ERROR_CODE: Readonly<Record<string, string>> = Object.freeze({
|
|
95
|
+
ERROR_PENDING_QUEUE_LIMIT: OfflineFailureReason.queueFull,
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
/** The `MessageFailureReason` carried by a per-send `onError`, if any. */
|
|
99
|
+
export function failureReasonFromError(error: unknown, reasonArg?: unknown): string {
|
|
100
|
+
const candidates = [reasonArg, (error as any)?.reason, (error as any)?.details?.reason];
|
|
101
|
+
for (const candidate of candidates) {
|
|
102
|
+
if (typeof candidate === "string" && KNOWN_REASONS.includes(candidate)) return candidate;
|
|
103
|
+
}
|
|
104
|
+
const code = (error as any)?.code ?? (error as any)?.name;
|
|
105
|
+
return (typeof code === "string" && REASON_BY_ERROR_CODE[code]) || "";
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** The SDK's "queued, not failed" notice (`errorParams.queued === true`, RN `OfflineErrors.ts`). */
|
|
109
|
+
export function isQueuedNotice(error: unknown): boolean {
|
|
110
|
+
return (error as any)?.errorParams?.queued === true || (error as any)?.details?.queued === true;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function isRefusal(reason: string): boolean {
|
|
114
|
+
return reason === OfflineFailureReason.queueFull || reason === OfflineFailureReason.byteOverflow;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function sdkSend(kind: OfflineSendKind, message: any, listener: any): unknown {
|
|
118
|
+
const sdk = offlineSdk();
|
|
119
|
+
switch (kind) {
|
|
120
|
+
case "media":
|
|
121
|
+
return sdk.sendMediaMessage(message, listener);
|
|
122
|
+
case "custom":
|
|
123
|
+
return sdk.sendCustomMessage(message, listener);
|
|
124
|
+
case "interactive":
|
|
125
|
+
return sdk.sendInteractiveMessage(message, listener);
|
|
126
|
+
default:
|
|
127
|
+
return sdk.sendMessage(message, listener);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* How long an online send waits, after its pending callback, for a further answer before the
|
|
133
|
+
* caller is released with "sending". The SDK may never give one for a while: a send queued behind
|
|
134
|
+
* an earlier unsent message in its chat gets `onMessagePending` and nothing else until that chat
|
|
135
|
+
* drains (SDK Outbox R77), and a chat can stall while online (R94).
|
|
136
|
+
*/
|
|
137
|
+
export const PENDING_ANSWER_WAIT_MS = 3000;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Send `message` on the offline path. Resolves once the SDK has answered the first time (sent,
|
|
141
|
+
* queued or failed); never rejects. Later transitions of a queued send arrive through the hub's
|
|
142
|
+
* outbox bridge and through `hooks`.
|
|
143
|
+
*
|
|
144
|
+
* A pending callback counts as the first answer ("sending") when the SDK is not connected (a
|
|
145
|
+
* send queued behind another unsent one gets no further callback, R77), and after
|
|
146
|
+
* {@link PENDING_ANSWER_WAIT_MS} online, so nothing that waits on this Promise (the composer's
|
|
147
|
+
* reply bar and recorder, the next send of a batch) is held by a send that is simply queued.
|
|
148
|
+
* An answer in the same tick as the pending (a queued notice, an iOS-order refusal) still wins.
|
|
149
|
+
*/
|
|
150
|
+
export function sendWithState(message: any, kind: OfflineSendKind, hooks: OfflineSendHooks = {}): Promise<OfflineSendResult> {
|
|
151
|
+
const hub = OfflineHub.getInstance();
|
|
152
|
+
return new Promise<OfflineSendResult>((resolve) => {
|
|
153
|
+
let pendingMessage: any = null;
|
|
154
|
+
let settled = false;
|
|
155
|
+
let finished = false;
|
|
156
|
+
// Set when the session ended or the cache was reset under this send: whatever the SDK says
|
|
157
|
+
// afterwards is stale and is dropped (Android `stale()`).
|
|
158
|
+
let ended = false;
|
|
159
|
+
let pendingWait: ReturnType<typeof setTimeout> | null = null;
|
|
160
|
+
const settle = (result: OfflineSendResult) => {
|
|
161
|
+
if (pendingWait !== null) {
|
|
162
|
+
clearTimeout(pendingWait);
|
|
163
|
+
pendingWait = null;
|
|
164
|
+
}
|
|
165
|
+
if (!settled) {
|
|
166
|
+
settled = true;
|
|
167
|
+
resolve(result);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const settleSendingAfterPending = () => {
|
|
171
|
+
if (settled || pendingWait !== null) return;
|
|
172
|
+
const asSending = () => settle({ state: "sending", message: pendingMessage ?? message });
|
|
173
|
+
if (sdkConnected() === false) {
|
|
174
|
+
// Offline: the pending callback is the answer for now. Let a same-tick answer win.
|
|
175
|
+
Promise.resolve().then(asSending);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
pendingWait = setTimeout(asSending, PENDING_ANSWER_WAIT_MS);
|
|
179
|
+
};
|
|
180
|
+
// A send waits for the SDK's answer. If the session ends (logout, user switch) or the SDK wipes
|
|
181
|
+
// its cache and loses the outbox, the listener it held is gone and no answer ever comes: settle
|
|
182
|
+
// the send here, once and quietly, with DISCARDED, as Android does (`rejectOpenCalls`,
|
|
183
|
+
// `rejectOpenCallsOnReset`). The session watch runs from the start of the send (a send the SDK
|
|
184
|
+
// never answers is open too); the reset watch from the first pending callback.
|
|
185
|
+
let resetWatch: Array<{ unsubscribe(): void }> = [];
|
|
186
|
+
let sessionWatch: { unsubscribe(): void } | null = null;
|
|
187
|
+
const stopResetWatch = () => {
|
|
188
|
+
resetWatch.forEach((w) => w.unsubscribe());
|
|
189
|
+
resetWatch = [];
|
|
190
|
+
};
|
|
191
|
+
const stopWatches = () => {
|
|
192
|
+
stopResetWatch();
|
|
193
|
+
sessionWatch?.unsubscribe();
|
|
194
|
+
sessionWatch = null;
|
|
195
|
+
};
|
|
196
|
+
/** End the send as a quiet DISCARDED failure: no failed row, no notice, no app error. */
|
|
197
|
+
const endQuietly = (why: string) => {
|
|
198
|
+
if (finished) return;
|
|
199
|
+
ended = true;
|
|
200
|
+
const target = pendingMessage ?? message;
|
|
201
|
+
const reason = OfflineFailureReason.discarded;
|
|
202
|
+
const error = quietDiscardError(why);
|
|
203
|
+
// No hub.reportFailure: the session is over, or the hub raises its own notice for the reset.
|
|
204
|
+
settle({ state: "failed", message: target, error, reason, quiet: true });
|
|
205
|
+
finishFailed(error, target, reason, false, true);
|
|
206
|
+
};
|
|
207
|
+
const watchForCacheReset = () => {
|
|
208
|
+
if (resetWatch.length > 0 || finished) return;
|
|
209
|
+
resetWatch = [
|
|
210
|
+
hub.cacheReset$.subscribe((event) => {
|
|
211
|
+
if (finished) return stopResetWatch();
|
|
212
|
+
if (event.pendingMessagesLost === 0) return; // the reset lost no queued send (BEH-ENC-15)
|
|
213
|
+
// ENCRYPTION_CHANGED fails each readable unsent message as DISCARDED first (R20/R136); any
|
|
214
|
+
// send still unanswered here was lost with the cache, as for every other reset reason.
|
|
215
|
+
endQuietly(`Message lost: the offline cache was reset (${event.reason || "unknown"})`);
|
|
216
|
+
}),
|
|
217
|
+
];
|
|
218
|
+
};
|
|
219
|
+
const finishSent = (sent: any) => {
|
|
220
|
+
if (finished) return;
|
|
221
|
+
finished = true;
|
|
222
|
+
stopWatches();
|
|
223
|
+
try { hooks.onSent?.(sent); } catch (e) { console.warn("[CometChatUIKit] onSent hook threw", e); }
|
|
224
|
+
};
|
|
225
|
+
const finishFailed = (error: unknown, failed: any, reason: string, direct: boolean, quiet = false) => {
|
|
226
|
+
if (finished) return;
|
|
227
|
+
finished = true;
|
|
228
|
+
stopWatches();
|
|
229
|
+
try { hooks.onFailed?.(error, failed, reason, direct, quiet); } catch (e) { console.warn("[CometChatUIKit] onFailed hook threw", e); }
|
|
230
|
+
};
|
|
231
|
+
const failDirect = (failed: any, error: unknown, reason: string) => {
|
|
232
|
+
hub.reportFailure(failed, reason, { direct: true });
|
|
233
|
+
settle({ state: "failed", message: failed, error, reason, direct: true });
|
|
234
|
+
finishFailed(error, failed, reason, true);
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const listener = {
|
|
238
|
+
onMessagePending: (pending: any) => {
|
|
239
|
+
if (ended) return;
|
|
240
|
+
pendingMessage = pending ?? message;
|
|
241
|
+
hub.reportSendState(pendingMessage, "sending", { announced: true });
|
|
242
|
+
watchForCacheReset();
|
|
243
|
+
settleSendingAfterPending();
|
|
244
|
+
},
|
|
245
|
+
onMessageSent: (sent: any) => {
|
|
246
|
+
if (ended) return;
|
|
247
|
+
hub.reportSendState(sent, "sent");
|
|
248
|
+
settle({ state: "sent", message: sent });
|
|
249
|
+
finishSent(sent);
|
|
250
|
+
},
|
|
251
|
+
onError: (error: unknown, reasonArg?: unknown) => {
|
|
252
|
+
if (ended) return;
|
|
253
|
+
const reason = failureReasonFromError(error, reasonArg);
|
|
254
|
+
if (isRefusal(reason)) {
|
|
255
|
+
// Queue full / too large: failed (direct) whatever came before (A7).
|
|
256
|
+
failDirect(pendingMessage ?? message, error, reason);
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
if (!pendingMessage && !isQueuedNotice(error)) {
|
|
260
|
+
// No pending came first: the SDK never queued it (BEH-SEND-33).
|
|
261
|
+
failDirect(message, error, reason);
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
const target = pendingMessage ?? message;
|
|
265
|
+
if (reason) {
|
|
266
|
+
// A final failure of a queued send (TRANSIENT / PERMANENT / DISCARDED / QUEUE_OVERFLOW).
|
|
267
|
+
hub.reportFailure(target, reason);
|
|
268
|
+
settle({ state: "failed", message: target, error, reason });
|
|
269
|
+
finishFailed(error, target, reason, false);
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
if (!isQueuedNotice(error) && statusOf(target) === OfflineMessageStatus.failed) {
|
|
273
|
+
hub.reportFailure(target, OfflineFailureReason.transient);
|
|
274
|
+
settle({ state: "failed", message: target, error, reason: OfflineFailureReason.transient });
|
|
275
|
+
finishFailed(error, target, OfflineFailureReason.transient, false);
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
// Queued, not failed (BEH-SEND-10): the row keeps the clock; the outbox reports the end.
|
|
279
|
+
settle({ state: "sending", message: target, error });
|
|
280
|
+
},
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
sessionWatch = hub.sessionEnd$.subscribe(() => endQuietly("The session ended before the message was sent."));
|
|
284
|
+
try {
|
|
285
|
+
const result: any = sdkSend(kind, message, listener);
|
|
286
|
+
// The SDK settles its Promise as well; offline it rejects for a queued send.
|
|
287
|
+
if (result && typeof result.then === "function") result.then(undefined, () => {});
|
|
288
|
+
} catch (error) {
|
|
289
|
+
console.warn("[CometChatUIKit] SDK send threw", error);
|
|
290
|
+
if (!pendingMessage && !ended) failDirect(message, error, failureReasonFromError(error));
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* The Promise contract of the public `CometChatUIKit.send*` statics on the ON path: resolves when
|
|
297
|
+
* the message is sent, rejects on a final failure, a direct error or a discard, and never because
|
|
298
|
+
* it was queued. Like Android (`OfflineSend.rejectOpenCalls`, `rejectOpenCallsOnReset`), it also
|
|
299
|
+
* rejects, once and quietly, with `ERROR_OFFLINE_MESSAGE_DISCARDED` when the session ends (logout
|
|
300
|
+
* or user switch) or the SDK's cache reset lost the queued send, so the Promise never stays
|
|
301
|
+
* unsettled. Kit callers treat that rejection as quiet ({@link isQuietRejection}).
|
|
302
|
+
*/
|
|
303
|
+
export function sendWithStatePromise(message: any, kind: OfflineSendKind): Promise<any> {
|
|
304
|
+
return new Promise<any>((resolve, reject) => {
|
|
305
|
+
const hub = OfflineHub.getInstance();
|
|
306
|
+
let watch: { unsubscribe(): void } | null = null;
|
|
307
|
+
const stop = () => {
|
|
308
|
+
watch?.unsubscribe();
|
|
309
|
+
watch = null;
|
|
310
|
+
};
|
|
311
|
+
sendWithState(message, kind, {
|
|
312
|
+
onSent: (sent) => {
|
|
313
|
+
stop();
|
|
314
|
+
resolve(sent);
|
|
315
|
+
},
|
|
316
|
+
onFailed: (error, failed, reason) => {
|
|
317
|
+
stop();
|
|
318
|
+
reject(error ?? Object.assign(new Error(reason || "Message send failed"), { code: reason, message: failed }));
|
|
319
|
+
},
|
|
320
|
+
}).then((first) => {
|
|
321
|
+
if (first.state !== "sending") return;
|
|
322
|
+
// A queued send that is later discarded releases its listener with no answer: reject then.
|
|
323
|
+
const localMessageId = localIdOf(first.message);
|
|
324
|
+
if (!localMessageId) return;
|
|
325
|
+
const startGen = hub.gen;
|
|
326
|
+
watch = hub.sendState$.subscribe((event) => {
|
|
327
|
+
// A session end or a reset settles the send itself (see sendWithState): nothing to do here.
|
|
328
|
+
if (hub.gen !== startGen) return stop();
|
|
329
|
+
if (event.localMessageId !== localMessageId || event.state !== "discarded") return;
|
|
330
|
+
stop();
|
|
331
|
+
reject(Object.assign(new Error("Message discarded"), { code: OfflineFailureReason.discarded, reason: event.reason }));
|
|
332
|
+
});
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Route one send: offline OFF → `today()` (the call site's existing code, unchanged); offline ON
|
|
339
|
+
* → {@link sendWithState}. The gate is read once here, when the user sends.
|
|
340
|
+
*/
|
|
341
|
+
export function routeSend<T>(message: any, kind: OfflineSendKind, today: () => T, hooks?: OfflineSendHooks): T | Promise<OfflineSendResult> {
|
|
342
|
+
if (!isOfflineOn()) return today();
|
|
343
|
+
return sendWithState(message, kind, hooks);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
/**
|
|
347
|
+
* Retry an unsent own message on the user's tap (UIK-SEND-07). Every unsent row offers it (R162 /
|
|
348
|
+
* S73): an outbox row (PENDING, SENDING or FAILED, any reason) is retried by the SDK
|
|
349
|
+
* (`retryMessage(localMessageId)`, the same row, never a second copy, so a retry on a row whose send is
|
|
350
|
+
* under way cannot duplicate the message); a direct failure is sent again as a fresh send through
|
|
351
|
+
* {@link sendWithState} (a new local id). A row whose send is under way is answered
|
|
352
|
+
* `ERROR_OFFLINE_MESSAGE_IN_FLIGHT` by the SDK, and the "Sending… try again in a moment" notice is
|
|
353
|
+
* raised. While a retry is in flight a further tap raises the same notice. A row the SDK no longer
|
|
354
|
+
* holds (`ERROR_OFFLINE_MESSAGE_NOT_FOUND`: its chat was purged after it failed, e.g. the user was
|
|
355
|
+
* removed from the group) has nothing left to send, so the row is removed, as Android does
|
|
356
|
+
* (`OfflineSend.retry` → `ActionResult.Removed`); a row the kit has seen sent is never removed.
|
|
357
|
+
*/
|
|
358
|
+
export function retryFailedMessage(message: any, kind: OfflineSendKind = sendKindOf(message), hooks?: OfflineSendHooks): boolean {
|
|
359
|
+
const hub = OfflineHub.getInstance();
|
|
360
|
+
const sdk = offlineSdk();
|
|
361
|
+
const localMessageId = localIdOf(message);
|
|
362
|
+
// Only a row the outbox does not hold is sent fresh: a direct failure (kept in memory), or one
|
|
363
|
+
// with no local id. A PENDING, SENDING or FAILED outbox row goes back through `retryMessage`, the
|
|
364
|
+
// same row, never a second copy (R162: Retry is offered on every unsent row).
|
|
365
|
+
const direct = hub.directFailureOf(message) !== undefined || !localMessageId;
|
|
366
|
+
if (direct) {
|
|
367
|
+
hub.clearDirectFailed(message);
|
|
368
|
+
// Same signal a retry gives with offline off: the row turns back to "sending" at once.
|
|
369
|
+
try {
|
|
370
|
+
CometChatUIEventHandler.emitMessageEvent("ccMessageSent", { message, status: "inprogress" });
|
|
371
|
+
} catch {
|
|
372
|
+
/* the pending callback will redraw the row */
|
|
373
|
+
}
|
|
374
|
+
sendWithState(message, kind, hooks);
|
|
375
|
+
return true;
|
|
376
|
+
}
|
|
377
|
+
if (typeof sdk.retryMessage !== "function") return false;
|
|
378
|
+
if (!hub.beginRetry(localMessageId)) {
|
|
379
|
+
// A retry of this row is still under way: say so instead of ignoring the tap.
|
|
380
|
+
hub.raiseSendInFlightNotice(message);
|
|
381
|
+
return false;
|
|
382
|
+
}
|
|
383
|
+
try {
|
|
384
|
+
sdk.retryMessage(localMessageId, {
|
|
385
|
+
onMessagePending: (pending: any) => hub.reportSendState(pending ?? message, "sending"),
|
|
386
|
+
onMessageSent: (sent: any) => {
|
|
387
|
+
hub.reportSendState(sent, "sent");
|
|
388
|
+
hooks?.onSent?.(sent);
|
|
389
|
+
},
|
|
390
|
+
onError: (error: unknown, reasonArg?: unknown) => {
|
|
391
|
+
hub.endRetry(localMessageId);
|
|
392
|
+
if (answerRetryRefusal(hub, message, error)) return;
|
|
393
|
+
const reason = failureReasonFromError(error, reasonArg);
|
|
394
|
+
// Not connected: it stays queued. Not retryable (unknown / not FAILED): nothing changed.
|
|
395
|
+
if (reason) hub.reportFailure(message, reason);
|
|
396
|
+
},
|
|
397
|
+
});
|
|
398
|
+
} catch (error) {
|
|
399
|
+
hub.endRetry(localMessageId);
|
|
400
|
+
if (!answerRetryRefusal(hub, message, error)) console.warn("[CometChatUIKit] retryMessage threw", error);
|
|
401
|
+
return false;
|
|
402
|
+
}
|
|
403
|
+
return true;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* The SDK refused a retry with a code that changes the row (Android `OfflineSend.retry`): IN_FLIGHT
|
|
408
|
+
* (the send is on the wire: nothing changed, the user is told) or NOT_FOUND (the SDK no longer
|
|
409
|
+
* holds the message: nothing is left to send, so the row goes; the hub never turns a row it saw
|
|
410
|
+
* sent into a removed one). False for any other answer.
|
|
411
|
+
*/
|
|
412
|
+
function answerRetryRefusal(hub: OfflineHub, message: any, error: unknown): boolean {
|
|
413
|
+
switch (errorCodeOf(error)) {
|
|
414
|
+
case DISCARD_ERROR.inFlight:
|
|
415
|
+
hub.raiseSendInFlightNotice(message);
|
|
416
|
+
return true;
|
|
417
|
+
case DISCARD_ERROR.notFound:
|
|
418
|
+
hub.reportDiscardedByUser(message);
|
|
419
|
+
return true;
|
|
420
|
+
default:
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/** Run `fn` once the ON-path send got its first answer; a no-op for the OFF path's return value. */
|
|
426
|
+
export function afterFirstAnswer(routed: unknown, fn: () => void): void {
|
|
427
|
+
if (routed && typeof (routed as any).then === "function") {
|
|
428
|
+
(routed as Promise<unknown>).then(fn, fn);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The UI Kit state contract (TEST-PLAN §3.3): automation identifiers (`testID`) that test runners
|
|
3
|
+
* read. They ship in release builds, are never read by screen readers (accessibility labels are
|
|
4
|
+
* untouched) and never contain message text. Elements that already carried a `testID` keep it
|
|
5
|
+
* (`message-list`, `CometChatComposer.send`, `ActionSheet.<optionId>`, `AttachmentTile-<n>`, …).
|
|
6
|
+
*
|
|
7
|
+
* | Element | testID |
|
|
8
|
+
* |--------------------|-----------------------------------------------------|
|
|
9
|
+
* | Message row | `cc.message.<renderKey>.<sending|sent|delivered|read|failed>` |
|
|
10
|
+
* | Notice | `cc.notice.<noticeKind>` (Copy: `cc.notice.copy`) |
|
|
11
|
+
* | List footer | `cc.list.footer.connect-to-load-more` |
|
|
12
|
+
* | Offline, no rows | `cc.empty.connect-to-load` / `cc.empty.connect-to-search` |
|
|
13
|
+
* | Composer input | `cc-composer-input` |
|
|
14
|
+
* | Conversation row | `cc.conversation.<with>.<sending|failed|sent|none>` |
|
|
15
|
+
* | Unreachable media | `cc.media.available-when-online` |
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
import { unsentRowInfo } from "./unsentActions";
|
|
20
|
+
|
|
21
|
+
export type ContractRowState = "sending" | "sent" | "delivered" | "read" | "failed";
|
|
22
|
+
|
|
23
|
+
function call(target: any, name: string): any {
|
|
24
|
+
try {
|
|
25
|
+
const fn = target?.[name];
|
|
26
|
+
return typeof fn === "function" ? fn.call(target) : undefined;
|
|
27
|
+
} catch {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The row state a runner reads: the offline state when unsent, else the receipt it shows. */
|
|
33
|
+
export function contractRowState(message: any): ContractRowState {
|
|
34
|
+
const info = unsentRowInfo(message);
|
|
35
|
+
if (info) return info.state === "failed" ? "failed" : "sending";
|
|
36
|
+
const metadataError = call(message, "getMetadata")?.error || call(message, "getData")?.metaData?.error || message?.error;
|
|
37
|
+
if (metadataError) return "failed";
|
|
38
|
+
if (call(message, "getReadAt")) return "read";
|
|
39
|
+
if (call(message, "getDeliveredAt")) return "delivered";
|
|
40
|
+
const id = Number(call(message, "getId") ?? message?.id);
|
|
41
|
+
if ((Number.isFinite(id) && id > 0) || call(message, "getSentAt")) return "sent";
|
|
42
|
+
return "sending";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function messageRowTestID(renderKey: string, message: any): string {
|
|
46
|
+
return `cc.message.${renderKey}.${contractRowState(message)}`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The row's id, for a dev build whose runner asked for it (`globalThis.__ccContractRows`); nothing at
|
|
51
|
+
* all otherwise, so a published row is the view tree it always was. A testID in a message row (on a
|
|
52
|
+
* wrapper or on the row's root) crashes Fabric on Android once a chat overflows the screen:
|
|
53
|
+
* `addViewAt: failed to insert view ... index=26 count=22`. It takes the testID,
|
|
54
|
+
* maintainVisibleContentPosition and the text bubble's hidden measuring Text together; the native
|
|
55
|
+
* mechanism is not established. `__DEV__` folds this out of release bundles (`probe:check`).
|
|
56
|
+
*/
|
|
57
|
+
export function messageRowContractProps(renderKey: string, message: any): { testID?: string; collapsable?: boolean } {
|
|
58
|
+
if (!__DEV__ || (globalThis as any).__ccContractRows !== true) return {};
|
|
59
|
+
// collapsable={false}: Fabric would flatten a style-less View away, and the id with it.
|
|
60
|
+
return { testID: messageRowTestID(renderKey, message), collapsable: false };
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** `cc.conversation.<with>.<previewState>` for a conversation row. */
|
|
64
|
+
export function conversationRowTestID(conversation: any): string {
|
|
65
|
+
const type = call(conversation, "getConversationType");
|
|
66
|
+
const entity = call(conversation, "getConversationWith");
|
|
67
|
+
const withId = (type === "group" ? call(entity, "getGuid") : call(entity, "getUid")) ?? "";
|
|
68
|
+
const last = call(conversation, "getLastMessage");
|
|
69
|
+
let preview = "none";
|
|
70
|
+
if (last) {
|
|
71
|
+
const info = unsentRowInfo(last);
|
|
72
|
+
preview = info ? (info.state === "failed" ? "failed" : "sending") : "sent";
|
|
73
|
+
}
|
|
74
|
+
return `cc.conversation.${withId}.${preview}`;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export const CONTRACT_IDS = Object.freeze({
|
|
78
|
+
composerInput: "cc-composer-input",
|
|
79
|
+
footerConnectToLoadMore: "cc.list.footer.connect-to-load-more",
|
|
80
|
+
emptyConnectToLoad: "cc.empty.connect-to-load",
|
|
81
|
+
emptyConnectToSearch: "cc.empty.connect-to-search",
|
|
82
|
+
noticeCopy: "cc.notice.copy",
|
|
83
|
+
mediaOutOfReach: "cc.media.available-when-online",
|
|
84
|
+
notice: (kind: string) => `cc.notice.${kind}`,
|
|
85
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The thread header's reply count on the offline (ON) path (README §3.9, UIT-SEND-21,
|
|
3
|
+
* BEH-MUT-10).
|
|
4
|
+
*
|
|
5
|
+
* The header shows the parent's `replyCount` as last delivered by the SDK (a cached parent already
|
|
6
|
+
* includes the user's own unsent replies). On top of it:
|
|
7
|
+
* - +1 per own reply `localMessageId` when this device sends it (its pending), once;
|
|
8
|
+
* - -1 when that reply is DISCARDED (or refused as failed direct) before it was sent;
|
|
9
|
+
* - nothing at the ack: the reply was counted at pending, and a reply that was already unsent when
|
|
10
|
+
* the header opened is in the parent's count. Today's +1 on the public success therefore runs
|
|
11
|
+
* only for a send the offline path did not handle (offline off: every send);
|
|
12
|
+
* - a fresher parent from the SDK (`onMessagesSynced`) replaces the value.
|
|
13
|
+
* So the count never goes up twice for one reply.
|
|
14
|
+
*
|
|
15
|
+
* Offline off nothing here fires: the hub's subjects are inert and no OFF message has a local id.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
import { localIdOf, muidOf, serverIdOf } from "./identity";
|
|
20
|
+
import type { MessagesUpdatedEvent, SendStateEvent } from "./OfflineHub";
|
|
21
|
+
|
|
22
|
+
export interface ThreadReplyTracker {
|
|
23
|
+
/** A hub `sendState$` event. */
|
|
24
|
+
onSendState(event: SendStateEvent): void;
|
|
25
|
+
/**
|
|
26
|
+
* Today's handling of the public `ccMessageSent` event: for `inprogress` it notes a reply
|
|
27
|
+
* composed on this device; for `success` it runs `todayIncrement` unless the offline path
|
|
28
|
+
* already counted (or the parent already includes) this reply.
|
|
29
|
+
*/
|
|
30
|
+
onPublicSent(message: any, status: string, todayIncrement: () => void): void;
|
|
31
|
+
/** A hub `messagesUpdated$` event: a fresher parent replaces the count. */
|
|
32
|
+
onMessagesUpdated(event: MessagesUpdatedEvent): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function parentIdOf(message: any): string {
|
|
36
|
+
try {
|
|
37
|
+
const id = typeof message?.getParentMessageId === "function" ? message.getParentMessageId() : message?.parentMessageId;
|
|
38
|
+
return id === undefined || id === null || id === 0 || id === "" ? "" : String(id);
|
|
39
|
+
} catch {
|
|
40
|
+
return "";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* @param parentId the thread's parent message id (read at each event)
|
|
46
|
+
* @param currentGen the hub's session `gen` (events of an older session are dropped)
|
|
47
|
+
* @param adjust add `delta` to the shown count
|
|
48
|
+
* @param replace show `count` (a fresher parent)
|
|
49
|
+
*/
|
|
50
|
+
export function createThreadReplyTracker(
|
|
51
|
+
parentId: () => string | number | undefined,
|
|
52
|
+
currentGen: () => number,
|
|
53
|
+
adjust: (delta: number) => void,
|
|
54
|
+
replace: (count: number) => void
|
|
55
|
+
): ThreadReplyTracker {
|
|
56
|
+
/** Own replies counted at pending and not sent yet: a discard takes the +1 back. */
|
|
57
|
+
const counted = new Set<string>();
|
|
58
|
+
/** Own replies the offline path reported sent: their public success adds nothing. */
|
|
59
|
+
const acked = new Set<string>();
|
|
60
|
+
/**
|
|
61
|
+
* muids of replies composed on this device while the header is open (the composer's
|
|
62
|
+
* `inprogress`). Only those are counted at pending: a retry keeps its first count, and an
|
|
63
|
+
* outbox replay after a relaunch is already in the parent's count.
|
|
64
|
+
*/
|
|
65
|
+
const composedHere = new Set<string>();
|
|
66
|
+
const cap = (set: Set<string>) => {
|
|
67
|
+
if (set.size > 500) set.delete(set.values().next().value as string);
|
|
68
|
+
};
|
|
69
|
+
const inThread = (message: any) => {
|
|
70
|
+
const parent = parentId();
|
|
71
|
+
return parent !== undefined && parent !== null && parentIdOf(message) !== "" && parentIdOf(message) === String(parent);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return {
|
|
75
|
+
onSendState(event) {
|
|
76
|
+
if (event.gen !== currentGen()) return;
|
|
77
|
+
const localMessageId = event.localMessageId;
|
|
78
|
+
if (!localMessageId || !inThread(event.message)) return;
|
|
79
|
+
switch (event.state) {
|
|
80
|
+
case "sending":
|
|
81
|
+
// Only a reply composed here; a retry or an outbox replay is already counted.
|
|
82
|
+
if (composedHere.has(muidOf(event.message)) && !counted.has(localMessageId) && !acked.has(localMessageId)) {
|
|
83
|
+
counted.add(localMessageId);
|
|
84
|
+
adjust(1);
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
case "sent":
|
|
88
|
+
counted.delete(localMessageId);
|
|
89
|
+
acked.add(localMessageId);
|
|
90
|
+
cap(acked);
|
|
91
|
+
return;
|
|
92
|
+
case "discarded":
|
|
93
|
+
if (counted.delete(localMessageId)) adjust(-1);
|
|
94
|
+
return;
|
|
95
|
+
case "failed":
|
|
96
|
+
// Refused (queue full / too large): never in the outbox, so not a reply after all.
|
|
97
|
+
if (event.direct && counted.delete(localMessageId)) adjust(-1);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
onPublicSent(message, status, todayIncrement) {
|
|
102
|
+
if (status === "inprogress") {
|
|
103
|
+
const muid = muidOf(message);
|
|
104
|
+
if (muid && inThread(message)) {
|
|
105
|
+
composedHere.add(muid);
|
|
106
|
+
cap(composedHere);
|
|
107
|
+
}
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
if (status !== "success") return;
|
|
111
|
+
const localMessageId = localIdOf(message);
|
|
112
|
+
if (localMessageId && (acked.has(localMessageId) || counted.has(localMessageId))) return;
|
|
113
|
+
todayIncrement();
|
|
114
|
+
},
|
|
115
|
+
onMessagesUpdated(event) {
|
|
116
|
+
if (event.gen !== currentGen()) return;
|
|
117
|
+
const parent = parentId();
|
|
118
|
+
if (parent === undefined || parent === null) return;
|
|
119
|
+
const fresher = event.messages.find((m) => serverIdOf(m) !== 0 && String(serverIdOf(m)) === String(parent));
|
|
120
|
+
if (!fresher || typeof fresher.getReplyCount !== "function") return;
|
|
121
|
+
const count = Number(fresher.getReplyCount());
|
|
122
|
+
if (Number.isFinite(count) && count >= 0) replace(count);
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|