diff --git a/ts/models/conversations.ts b/ts/models/conversations.ts index 7ff9d58436f..4fe31e13526 100644 --- a/ts/models/conversations.ts +++ b/ts/models/conversations.ts @@ -7,6 +7,7 @@ import { ConversationAttributesType, VerificationOptions, } from '../model-types.d'; +import { CallHistoryDetailsType } from '../types/Calling'; import { CallbackResultType, GroupV2InfoType } from '../textsecure/SendMessage'; import { ConversationType, @@ -1843,7 +1844,7 @@ export class ConversationModel extends window.Backbone.Model< } async addCallHistory( - callHistoryDetails: Record + callHistoryDetails: CallHistoryDetailsType ): Promise { const { acceptedTime, endedTime, wasDeclined } = callHistoryDetails; const message = ({ diff --git a/ts/services/calling.ts b/ts/services/calling.ts index e60dcc7e825..11380cff99f 100644 --- a/ts/services/calling.ts +++ b/ts/services/calling.ts @@ -26,11 +26,7 @@ import { CallDetailsType, } from '../state/ducks/calling'; import { EnvelopeClass } from '../textsecure.d'; -import { - AudioDevice, - CallHistoryDetailsType, - MediaDeviceSettings, -} from '../types/Calling'; +import { AudioDevice, MediaDeviceSettings } from '../types/Calling'; import { ConversationModel } from '../models/conversations'; export { @@ -868,36 +864,34 @@ export class CallingClass { acceptedTime = Date.now(); } - const callHistoryDetails: CallHistoryDetailsType = { + conversation.addCallHistory({ wasIncoming: call.isIncoming, wasVideoCall: call.isVideoCall, wasDeclined, acceptedTime, endedTime: Date.now(), - }; - conversation.addCallHistory(callHistoryDetails); + }); } private addCallHistoryForFailedIncomingCall( conversation: ConversationModel, wasVideoCall: boolean ) { - const callHistoryDetails: CallHistoryDetailsType = { + conversation.addCallHistory({ wasIncoming: true, wasVideoCall, // Since the user didn't decline, make sure it shows up as a missed call instead wasDeclined: false, acceptedTime: undefined, endedTime: Date.now(), - }; - conversation.addCallHistory(callHistoryDetails); + }); } private addCallHistoryForAutoEndedIncomingCall( conversation: ConversationModel, _reason: CallEndedReason ) { - const callHistoryDetails: CallHistoryDetailsType = { + conversation.addCallHistory({ wasIncoming: true, // We don't actually know, but it doesn't seem that important in this case, // but we could maybe plumb this info through RingRTC @@ -906,8 +900,7 @@ export class CallingClass { wasDeclined: false, acceptedTime: undefined, endedTime: Date.now(), - }; - conversation.addCallHistory(callHistoryDetails); + }); } }