Skip to content

Commit 6ea2078

Browse files
committed
simplified and fixed getTextDescriptionForCallevent
1 parent ba360e1 commit 6ea2078

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

src/util/callEventHelper.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,40 +32,25 @@ function formatDuration(durationInMilliSeconds: number): string {
3232
.substring(0, 2);
3333
return `${minutes}:${seconds} min`;
3434
}
35+
3536
export const getTextDescriptionForCallevent = (
3637
callEvent: CallEvent,
3738
): string => {
3839
const date = new Date(callEvent.startTime);
3940
const duration = formatDuration(callEvent.endTime - callEvent.startTime);
4041
const directionInfo =
4142
callEvent.direction === CallDirection.IN ? 'eingehender' : 'ausgehender';
42-
let callDescription: string;
43-
if (callEvent.direction === CallDirection.IN) {
44-
callDescription = ` von ${
45-
callEvent.participants.find((x) => x.type == CallParticipantType.REMOTE)
46-
?.phoneNumber
47-
} auf
48-
${
49-
callEvent.participants.find((x) => x.type == CallParticipantType.LOCAL)
50-
?.phoneNumber
51-
}`;
52-
} else {
53-
callDescription = ` von ${
54-
callEvent.participants.find((x) => x.type == CallParticipantType.LOCAL)
55-
?.phoneNumber
56-
} auf
57-
${
58-
callEvent.participants.find((x) => x.type == CallParticipantType.REMOTE)
59-
?.phoneNumber
60-
}`;
61-
}
62-
43+
const { from, to } = getCallMembers(callEvent);
44+
const fromDescription = from ? ` von ${from}` : '';
45+
const toDescription = to ? ` auf ${to}` : '';
46+
const callDescription = `${fromDescription}${toDescription}`;
6347
const callState =
6448
callEvent.state === 'MISSED' ? 'Nicht angenommener ' : 'Angenommener';
6549
const durationInfo =
6650
callEvent.state === 'MISSED' ? '' : ` ,Dauer: ${duration}`;
67-
return `${callState} ${directionInfo} Anruf ${callDescription} am ${date.toLocaleString(
51+
const result = `${callState} ${directionInfo} Anruf ${callDescription} am ${date.toLocaleString(
6852
'de',
6953
{ timeZone: 'Europe/Berlin' },
7054
)} ${durationInfo}`;
55+
return result;
7156
};

0 commit comments

Comments
 (0)