When a group call starts, show an OS notification

This commit is contained in:
Evan Hahn 2021-09-24 09:01:01 -05:00 committed by GitHub
parent 68b711b360
commit 9aa0de5b6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 105 additions and 28 deletions

View file

@ -9,16 +9,10 @@ import {
CallsByConversationType,
DirectCallStateType,
GroupCallStateType,
isAnybodyElseInGroupCall,
getIncomingCall as getIncomingCallHelper,
} from '../ducks/calling';
import {
CallMode,
CallState,
GroupCallConnectionState,
} from '../../types/Calling';
import { getUserUuid } from './user';
import { getOwn } from '../../util/getOwn';
import { missingCaseError } from '../../util/missingCaseError';
export type CallStateType = DirectCallStateType | GroupCallStateType;
@ -62,29 +56,12 @@ export const isInCall = createSelector(
(call: CallStateType | undefined): boolean => Boolean(call)
);
// In theory, there could be multiple incoming calls, or an incoming call while there's
// an active call. In practice, the UI is not ready for this, and RingRTC doesn't
// support it for direct calls.
export const getIncomingCall = createSelector(
getCallsByConversation,
getUserUuid,
(
callsByConversation: CallsByConversationType,
ourUuid: string
): undefined | DirectCallStateType | GroupCallStateType => {
return Object.values(callsByConversation).find(call => {
switch (call.callMode) {
case CallMode.Direct:
return call.isIncoming && call.callState === CallState.Ringing;
case CallMode.Group:
return (
call.ringerUuid &&
call.connectionState === GroupCallConnectionState.NotConnected &&
isAnybodyElseInGroupCall(call.peekInfo, ourUuid)
);
default:
throw missingCaseError(call);
}
});
}
): undefined | DirectCallStateType | GroupCallStateType =>
getIncomingCallHelper(callsByConversation, ourUuid)
);