Add type for ConversationModel#getGroupV1Info

This commit is contained in:
Evan Hahn 2021-08-23 18:15:34 -05:00 committed by GitHub
parent d5d808651a
commit 52328c2634
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View file

@ -15,7 +15,10 @@ import {
import { AttachmentType } from '../types/Attachment'; import { AttachmentType } from '../types/Attachment';
import { CallMode, CallHistoryDetailsType } from '../types/Calling'; import { CallMode, CallHistoryDetailsType } from '../types/Calling';
import * as Stickers from '../types/Stickers'; import * as Stickers from '../types/Stickers';
import { GroupV2InfoType } from '../textsecure/SendMessage'; import type {
GroupV1InfoType,
GroupV2InfoType,
} from '../textsecure/SendMessage';
import createTaskWithTimeout from '../textsecure/TaskWithTimeout'; import createTaskWithTimeout from '../textsecure/TaskWithTimeout';
import { CallbackResultType } from '../textsecure/Types.d'; import { CallbackResultType } from '../textsecure/Types.d';
import { ConversationType } from '../state/ducks/conversations'; import { ConversationType } from '../state/ducks/conversations';
@ -1134,17 +1137,20 @@ export class ConversationModel extends window.Backbone
}; };
} }
getGroupV1Info(): WhatIsThis { getGroupV1Info(): GroupV1InfoType | undefined {
const groupId = this.get('groupId');
const groupVersion = this.get('groupVersion');
if ( if (
isDirectConversation(this.attributes) || isDirectConversation(this.attributes) ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion !groupId ||
this.get('groupVersion')! > 0 (groupVersion && groupVersion > 0)
) { ) {
return undefined; return undefined;
} }
return { return {
id: this.get('groupId'), id: groupId,
members: this.getRecipients(), members: this.getRecipients(),
}; };
} }

View file

@ -94,7 +94,7 @@ export type GroupV2InfoType = {
revision: number; revision: number;
members: Array<string>; members: Array<string>;
}; };
type GroupV1InfoType = { export type GroupV1InfoType = {
id: string; id: string;
members: Array<string>; members: Array<string>;
}; };