@xmoxmo/bncr 0.3.5 → 0.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
CHANGED
|
@@ -79,10 +79,25 @@ export type ReplyMediaFallbackTextEntryParams = {
|
|
|
79
79
|
fallback: { text: string; reason: string };
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
const MEDIA_TEXT_SPLIT_THRESHOLD = 1020;
|
|
83
|
+
|
|
82
84
|
export function hasReplyMediaEntries(payload: NormalizedReplyPayload) {
|
|
83
85
|
return payload.mediaList.length > 0;
|
|
84
86
|
}
|
|
85
87
|
|
|
88
|
+
export function shouldSplitReplyMediaText(payload: NormalizedReplyPayload) {
|
|
89
|
+
if (!payload.text) return false;
|
|
90
|
+
if (payload.mediaList.length > 1) return true;
|
|
91
|
+
return payload.text.length > MEDIA_TEXT_SPLIT_THRESHOLD;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function withoutReplyMediaText(payload: NormalizedReplyPayload): NormalizedReplyPayload {
|
|
95
|
+
return {
|
|
96
|
+
...payload,
|
|
97
|
+
text: '',
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
86
101
|
export function buildReplyTextOutboxEntry(
|
|
87
102
|
params: {
|
|
88
103
|
accountId: string;
|
|
@@ -310,6 +325,23 @@ export function enqueueNormalizedReplyPayload(
|
|
|
310
325
|
});
|
|
311
326
|
|
|
312
327
|
if (helpers.hasReplyMediaEntries(params.payload)) {
|
|
328
|
+
if (shouldSplitReplyMediaText(params.payload)) {
|
|
329
|
+
helpers.enqueueReplyTextEntry({
|
|
330
|
+
accountId: params.accountId,
|
|
331
|
+
sessionKey: params.sessionKey,
|
|
332
|
+
route: params.route,
|
|
333
|
+
payload: params.payload,
|
|
334
|
+
});
|
|
335
|
+
helpers.enqueueReplyMediaEntries({
|
|
336
|
+
accountId: params.accountId,
|
|
337
|
+
sessionKey: params.sessionKey,
|
|
338
|
+
route: params.route,
|
|
339
|
+
payload: withoutReplyMediaText(params.payload),
|
|
340
|
+
mediaLocalRoots: params.mediaLocalRoots,
|
|
341
|
+
});
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
|
|
313
345
|
helpers.enqueueReplyMediaEntries({
|
|
314
346
|
accountId: params.accountId,
|
|
315
347
|
sessionKey: params.sessionKey,
|