Update CallLogEvent to latest spec

This commit is contained in:
Jamie Kyle 2024-06-25 17:58:38 -07:00 committed by GitHub
parent 815fd77849
commit fc08e70c0f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 366 additions and 142 deletions

View file

@ -4,7 +4,11 @@
import { createSelector } from 'reselect';
import type { CallHistoryState } from '../ducks/callHistory';
import type { StateType } from '../reducer';
import type { CallHistoryDetails } from '../../types/CallDisposition';
import {
AdhocCallStatus,
CallType,
type CallHistoryDetails,
} from '../../types/CallDisposition';
import { getOwn } from '../../util/getOwn';
const getCallHistory = (state: StateType): CallHistoryState =>
@ -36,3 +40,28 @@ export const getCallHistoryUnreadCount = createSelector(
return callHistory.unreadCount;
}
);
export const getCallHistoryLatestCall = createSelector(
getCallHistory,
callHistory => {
let latestCall = null;
for (const callId of Object.keys(callHistory.callHistoryByCallId)) {
const call = callHistory.callHistoryByCallId[callId];
// Skip unused call links
if (
call.type === CallType.Adhoc &&
call.status === AdhocCallStatus.Pending
) {
continue;
}
if (latestCall == null || call.timestamp > latestCall.timestamp) {
latestCall = call;
}
}
return latestCall;
}
);