Ensure left pane has correct timestamp for call
This commit is contained in:
parent
ad9dcb34f4
commit
06f71a7ef8
6 changed files with 62 additions and 29 deletions
|
@ -165,6 +165,7 @@ import OS from '../util/os/osMain';
|
|||
import { getMessageAuthorText } from '../util/getMessageAuthorText';
|
||||
import { downscaleOutgoingAttachment } from '../util/attachments';
|
||||
import { MessageRequestResponseEvent } from '../types/MessageRequestResponseEvent';
|
||||
import { getCallHistorySelector } from '../state/selectors/callHistory';
|
||||
|
||||
/* eslint-disable more/no-then */
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
@ -4190,7 +4191,13 @@ export class ConversationModel extends window.Backbone
|
|||
let lastMessageReceivedAt = this.get('lastMessageReceivedAt');
|
||||
let lastMessageReceivedAtMs = this.get('lastMessageReceivedAtMs');
|
||||
if (activityMessage) {
|
||||
const callId = activityMessage.get('callId');
|
||||
const callHistory = callId
|
||||
? getCallHistorySelector(window.reduxStore.getState())(callId)
|
||||
: undefined;
|
||||
|
||||
timestamp =
|
||||
callHistory?.timestamp ||
|
||||
activityMessage.get('editMessageTimestamp') ||
|
||||
activityMessage.get('sent_at') ||
|
||||
timestamp;
|
||||
|
|
|
@ -2216,7 +2216,8 @@ export class CallingClass {
|
|||
);
|
||||
await updateCallHistoryFromLocalEvent(
|
||||
callEvent,
|
||||
envelope.receivedAtCounter
|
||||
envelope.receivedAtCounter,
|
||||
envelope.receivedAtDate
|
||||
);
|
||||
|
||||
return;
|
||||
|
@ -2500,7 +2501,7 @@ export class CallingClass {
|
|||
localEventForCall,
|
||||
'CallingClass.handleGroupCallRingUpdate'
|
||||
);
|
||||
await updateCallHistoryFromLocalEvent(callEvent, null);
|
||||
await updateCallHistoryFromLocalEvent(callEvent, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2588,7 +2589,7 @@ export class CallingClass {
|
|||
localCallEvent,
|
||||
'CallingClass.handleIncomingCall'
|
||||
);
|
||||
await updateCallHistoryFromLocalEvent(callEvent, null);
|
||||
await updateCallHistoryFromLocalEvent(callEvent, null, null);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -2613,7 +2614,9 @@ export class CallingClass {
|
|||
callEndedReason: CallEndedReason,
|
||||
ageInSeconds: number,
|
||||
wasVideoCall: boolean,
|
||||
receivedAtCounter: number | undefined
|
||||
receivedAtCounter: number | undefined,
|
||||
// TODO: DESKTOP-7145
|
||||
receivedAtMS: number | undefined = undefined
|
||||
) {
|
||||
const conversation = window.ConversationController.get(remoteUserId);
|
||||
if (!conversation) {
|
||||
|
@ -2645,7 +2648,11 @@ export class CallingClass {
|
|||
localCallEvent,
|
||||
'CallingClass.handleAutoEndedIncomingCallRequest'
|
||||
);
|
||||
await updateCallHistoryFromLocalEvent(callEvent, receivedAtCounter ?? null);
|
||||
await updateCallHistoryFromLocalEvent(
|
||||
callEvent,
|
||||
receivedAtCounter ?? null,
|
||||
receivedAtMS ?? null
|
||||
);
|
||||
}
|
||||
|
||||
private attachToCall(conversation: ConversationModel, call: Call): void {
|
||||
|
@ -2679,7 +2686,7 @@ export class CallingClass {
|
|||
localCallEvent,
|
||||
'call.handleStateChanged'
|
||||
);
|
||||
await updateCallHistoryFromLocalEvent(callEvent, null);
|
||||
await updateCallHistoryFromLocalEvent(callEvent, null, null);
|
||||
}
|
||||
|
||||
reduxInterface.callStateChange({
|
||||
|
@ -2966,7 +2973,7 @@ export class CallingClass {
|
|||
localCallEvent,
|
||||
'CallingClass.updateCallHistoryForGroupCallOnLocalChanged'
|
||||
);
|
||||
await updateCallHistoryFromLocalEvent(callEvent, null);
|
||||
await updateCallHistoryFromLocalEvent(callEvent, null, null);
|
||||
} catch (error) {
|
||||
log.error(
|
||||
'CallingClass.updateCallHistoryForGroupCallOnLocalChanged: Error updating state',
|
||||
|
@ -3022,7 +3029,7 @@ export class CallingClass {
|
|||
localCallEvent,
|
||||
'CallingClass.updateCallHistoryForGroupCallOnPeek'
|
||||
);
|
||||
await updateCallHistoryFromLocalEvent(callEvent, null);
|
||||
await updateCallHistoryFromLocalEvent(callEvent, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3501,7 +3501,7 @@ export default class MessageReceiver
|
|||
|
||||
logUnexpectedUrgentValue(envelope, 'callEventSync');
|
||||
|
||||
const { receivedAtCounter } = envelope;
|
||||
const { receivedAtCounter, receivedAtDate: receivedAtMS } = envelope;
|
||||
|
||||
const callEventDetails = getCallEventForProto(
|
||||
callEvent,
|
||||
|
@ -3512,6 +3512,7 @@ export default class MessageReceiver
|
|||
{
|
||||
callEventDetails,
|
||||
receivedAtCounter,
|
||||
receivedAtMS,
|
||||
},
|
||||
this.removeFromCache.bind(this, envelope)
|
||||
);
|
||||
|
|
|
@ -429,6 +429,7 @@ export class ViewSyncEvent extends ConfirmableEvent {
|
|||
export type CallEventSyncEventData = Readonly<{
|
||||
callEventDetails: CallEventDetails;
|
||||
receivedAtCounter: number;
|
||||
receivedAtMS: number;
|
||||
}>;
|
||||
|
||||
export class CallEventSyncEvent extends ConfirmableEvent {
|
||||
|
|
|
@ -848,7 +848,8 @@ function transitionAdhocCallStatus(
|
|||
|
||||
async function updateLocalCallHistory(
|
||||
callEvent: CallEventDetails,
|
||||
receivedAtCounter: number | null
|
||||
receivedAtCounter: number | null,
|
||||
receivedAtMS: number | null
|
||||
): Promise<CallHistoryDetails | null> {
|
||||
const conversation = window.ConversationController.get(callEvent.peerId);
|
||||
strictAssert(
|
||||
|
@ -892,11 +893,12 @@ async function updateLocalCallHistory(
|
|||
return null;
|
||||
}
|
||||
|
||||
const updatedCallHistory = await saveCallHistory(
|
||||
const updatedCallHistory = await saveCallHistory({
|
||||
callHistory,
|
||||
conversation,
|
||||
receivedAtCounter
|
||||
);
|
||||
receivedAtCounter,
|
||||
receivedAtMS,
|
||||
});
|
||||
return updatedCallHistory;
|
||||
}
|
||||
);
|
||||
|
@ -977,11 +979,17 @@ export async function updateLocalAdhocCallHistory(
|
|||
return callHistory;
|
||||
}
|
||||
|
||||
async function saveCallHistory(
|
||||
callHistory: CallHistoryDetails,
|
||||
conversation: ConversationModel,
|
||||
receivedAtCounter: number | null
|
||||
): Promise<CallHistoryDetails> {
|
||||
async function saveCallHistory({
|
||||
callHistory,
|
||||
conversation,
|
||||
receivedAtCounter,
|
||||
receivedAtMS,
|
||||
}: {
|
||||
callHistory: CallHistoryDetails;
|
||||
conversation: ConversationModel;
|
||||
receivedAtCounter: number | null;
|
||||
receivedAtMS: number | null;
|
||||
}): Promise<CallHistoryDetails> {
|
||||
log.info(
|
||||
'saveCallHistory: Saving call history:',
|
||||
formatCallHistory(callHistory)
|
||||
|
@ -1052,7 +1060,8 @@ async function saveCallHistory(
|
|||
prevMessage?.received_at ??
|
||||
receivedAtCounter ??
|
||||
incrementMessageCounter(),
|
||||
received_at_ms: prevMessage?.received_at_ms ?? callHistory.timestamp,
|
||||
received_at_ms:
|
||||
prevMessage?.received_at_ms ?? receivedAtMS ?? callHistory.timestamp,
|
||||
readStatus: ReadStatus.Read,
|
||||
seenStatus,
|
||||
callId: callHistory.callId,
|
||||
|
@ -1153,10 +1162,11 @@ async function updateRemoteCallHistory(
|
|||
|
||||
export async function updateCallHistoryFromRemoteEvent(
|
||||
callEvent: CallEventDetails,
|
||||
receivedAtCounter: number
|
||||
receivedAtCounter: number,
|
||||
receivedAtMS: number
|
||||
): Promise<void> {
|
||||
if (callEvent.mode === CallMode.Direct || callEvent.mode === CallMode.Group) {
|
||||
await updateLocalCallHistory(callEvent, receivedAtCounter);
|
||||
await updateLocalCallHistory(callEvent, receivedAtCounter, receivedAtMS);
|
||||
} else if (callEvent.mode === CallMode.Adhoc) {
|
||||
await updateLocalAdhocCallHistory(callEvent);
|
||||
}
|
||||
|
@ -1164,11 +1174,13 @@ export async function updateCallHistoryFromRemoteEvent(
|
|||
|
||||
export async function updateCallHistoryFromLocalEvent(
|
||||
callEvent: CallEventDetails,
|
||||
receivedAtCounter: number | null
|
||||
receivedAtCounter: number | null,
|
||||
receivedAtMS: number | null
|
||||
): Promise<void> {
|
||||
const updatedCallHistory = await updateLocalCallHistory(
|
||||
callEvent,
|
||||
receivedAtCounter
|
||||
receivedAtCounter,
|
||||
receivedAtMS
|
||||
);
|
||||
if (updatedCallHistory == null) {
|
||||
return;
|
||||
|
@ -1303,14 +1315,15 @@ export async function updateLocalGroupCallHistoryTimestamp(
|
|||
return prevCallHistory;
|
||||
}
|
||||
|
||||
const updatedCallHistory = await saveCallHistory(
|
||||
{
|
||||
const updatedCallHistory = await saveCallHistory({
|
||||
callHistory: {
|
||||
...prevCallHistory,
|
||||
timestamp,
|
||||
},
|
||||
conversation,
|
||||
null
|
||||
);
|
||||
receivedAtCounter: null,
|
||||
receivedAtMS: null,
|
||||
});
|
||||
|
||||
return updatedCallHistory;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ export async function onCallEventSync(
|
|||
syncEvent: CallEventSyncEvent
|
||||
): Promise<void> {
|
||||
const { callEvent, confirm } = syncEvent;
|
||||
const { callEventDetails, receivedAtCounter } = callEvent;
|
||||
const { callEventDetails, receivedAtCounter, receivedAtMS } = callEvent;
|
||||
|
||||
if (
|
||||
callEventDetails.mode === CallMode.Direct ||
|
||||
|
@ -31,6 +31,10 @@ export async function onCallEventSync(
|
|||
}
|
||||
}
|
||||
|
||||
await updateCallHistoryFromRemoteEvent(callEventDetails, receivedAtCounter);
|
||||
await updateCallHistoryFromRemoteEvent(
|
||||
callEventDetails,
|
||||
receivedAtCounter,
|
||||
receivedAtMS
|
||||
);
|
||||
confirm();
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue