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