Pass abortSignal to sendToGroup

This commit is contained in:
Fedor Indutny 2022-05-23 15:08:13 -07:00 committed by GitHub
parent 7afe3fcca2
commit 3be95e821e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 49 additions and 26 deletions

View file

@ -89,6 +89,7 @@ export type SenderKeyTargetType = {
};
export async function sendToGroup({
abortSignal,
contentHint,
groupSendOptions,
isPartialSend,
@ -97,6 +98,7 @@ export async function sendToGroup({
sendTarget,
sendType,
}: {
abortSignal?: AbortSignal;
contentHint: number;
groupSendOptions: GroupSendOptionsType;
isPartialSend?: boolean;
@ -120,6 +122,12 @@ export async function sendToGroup({
protoAttributes
);
// Attachment upload might take too long to succeed - we don't want to proceed
// with the send if the caller aborted this call.
if (abortSignal?.aborted) {
throw new Error('sendToGroup was aborted');
}
return sendContentMessageToGroup({
contentHint,
contentMessage,