Streamlined system messages

This commit is contained in:
Josh Perez 2021-08-26 16:51:55 -04:00 committed by GitHub
parent 1973224adb
commit 2b08cbfdfe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
57 changed files with 864 additions and 937 deletions

View file

@ -110,3 +110,53 @@ export function getCallingNotificationText(
return '';
}
}
type CallingIconType =
| 'audio-incoming'
| 'audio-missed'
| 'audio-outgoing'
| 'phone'
| 'video'
| 'video-incoming'
| 'video-missed'
| 'video-outgoing';
function getDirectCallingIcon({
wasIncoming,
wasVideoCall,
acceptedTime,
}: DirectCallNotificationType): CallingIconType {
const wasAccepted = Boolean(acceptedTime);
// video
if (wasVideoCall) {
if (wasAccepted) {
return wasIncoming ? 'video-incoming' : 'video-outgoing';
}
return 'video-missed';
}
if (wasAccepted) {
return wasIncoming ? 'audio-incoming' : 'audio-outgoing';
}
return 'audio-missed';
}
export function getCallingIcon(
notification: CallingNotificationType
): CallingIconType {
switch (notification.callMode) {
case CallMode.Direct:
return getDirectCallingIcon(notification);
case CallMode.Group:
return 'video';
default:
window.log.error(
`getCallingNotificationText: missing case ${missingCaseError(
notification
)}`
);
return 'phone';
}
}