fix: batch resend of group updates 20 at a time

pull/3281/head
Audric Ackermann 9 months ago
parent 5cda9ad0f3
commit e697387932
No known key found for this signature in database

@ -132,7 +132,7 @@ function propsToTuple<T extends MergedLocalizerTokens>(
* @deprecated this will eventually be replaced by LocalizedStringBuilder
*
* @param token - The token identifying the message to retrieve.
* @param args - An optional record of substitution variables and their replacement values. This is equired if the string has dynamic variables.
* @param args - An optional record of substitution variables and their replacement values. This is required if the string has dynamic variables.
*/
export const inEnglish: I18nMethods['inEnglish'] = token => {
if (!isSimpleToken(token)) {

@ -235,7 +235,10 @@ async function allFailedToSentGroupControlMessagesToRetry(groupPk: GroupPubkeyTy
try {
const sodium = await getSodiumRenderer();
const msgsToResend = await Data.fetchAllGroupUpdateFailedMessage(groupPk);
const firstChunk = msgsToResend.slice(0, Math.floor(MAX_SUBREQUESTS_COUNT / 2));
if (!msgsToResend.length) {
return;
}
const firstChunk = msgsToResend.slice(0, Math.floor(MAX_SUBREQUESTS_COUNT));
const convo = ConvoHub.use().get(groupPk);
if (!convo) {
throw new Error('allFailedToSentGroupControlMessagesToRetry: convo not found');
@ -325,12 +328,21 @@ async function allFailedToSentGroupControlMessagesToRetry(groupPk: GroupPubkeyTy
if (!extraStoreRequests.length) {
return;
}
await pushChangesToGroupSwarmIfNeeded({
groupPk,
extraStoreRequests,
allow401s: false,
});
const controller = new AbortController();
// we don't really care about the result. The messages in DB will get their state
// updated as part of sendEncryptedDataToSnode
await timeoutWithAbort(
MessageSender.sendEncryptedDataToSnode({
sortedSubRequests: extraStoreRequests,
destination: groupPk,
method: 'sequence',
abortSignal: controller.signal,
allow401s: false,
}),
30 * DURATION.SECONDS,
controller
);
} catch (e) {
window.log.warn('failed');
}

Loading…
Cancel
Save