Refactor SendMessage.ts to named parameters

This commit is contained in:
Scott Nonnenberg 2021-07-02 11:34:17 -07:00 committed by GitHub
parent 56933192ba
commit 615ae1ccf7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 540 additions and 470 deletions

View file

@ -55,13 +55,19 @@ const MAX_RECURSION = 5;
// Public API:
export async function sendToGroup(
groupSendOptions: GroupSendOptionsType,
conversation: ConversationModel,
contentHint: number,
sendOptions?: SendOptionsType,
isPartialSend?: boolean
): Promise<CallbackResultType> {
export async function sendToGroup({
groupSendOptions,
conversation,
contentHint,
sendOptions,
isPartialSend,
}: {
groupSendOptions: GroupSendOptionsType;
conversation: ConversationModel;
contentHint: number;
sendOptions?: SendOptionsType;
isPartialSend?: boolean;
}): Promise<CallbackResultType> {
assert(
window.textsecure.messaging,
'sendToGroup: textsecure.messaging not available!'
@ -145,14 +151,14 @@ export async function sendContentMessageToGroup({
const groupId = isGroupV2(conversation.attributes)
? conversation.get('groupId')
: undefined;
return window.textsecure.messaging.sendGroupProto(
return window.textsecure.messaging.sendGroupProto({
recipients,
contentMessage,
proto: contentMessage,
timestamp,
contentHint,
groupId,
{ ...sendOptions, online }
);
options: { ...sendOptions, online },
});
}
// The Primary Sender Key workflow
@ -433,14 +439,14 @@ export async function sendToGroupViaSenderKey(options: {
// 12. Send normal message to the leftover normal recipients. Then combine normal send
// result with result from sender key send for final return value.
const normalSendResult = await window.textsecure.messaging.sendGroupProto(
normalRecipients,
contentMessage,
const normalSendResult = await window.textsecure.messaging.sendGroupProto({
recipients: normalRecipients,
proto: contentMessage,
timestamp,
contentHint,
groupId,
{ ...sendOptions, online }
);
options: { ...sendOptions, online },
});
return {
dataMessage: contentMessage.dataMessage?.toArrayBuffer(),