Redux state: Allow multiple calls to be stored
This commit is contained in:
parent
753e0279c6
commit
3468de255d
21 changed files with 1191 additions and 515 deletions
33
ts/state/selectors/calling.ts
Normal file
33
ts/state/selectors/calling.ts
Normal file
|
@ -0,0 +1,33 @@
|
|||
// Copyright 2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
import { CallingStateType } from '../ducks/calling';
|
||||
import { CallState } from '../../types/Calling';
|
||||
import { getOwn } from '../../util/getOwn';
|
||||
|
||||
const getActiveCallState = (state: CallingStateType) => state.activeCallState;
|
||||
|
||||
const getCallsByConversation = (state: CallingStateType) =>
|
||||
state.callsByConversation;
|
||||
|
||||
// In theory, there could be multiple incoming calls. In practice, neither RingRTC nor the
|
||||
// UI are ready to handle this.
|
||||
export const getIncomingCall = createSelector(
|
||||
getCallsByConversation,
|
||||
callsByConversation =>
|
||||
Object.values(callsByConversation).find(
|
||||
call => call.isIncoming && call.callState === CallState.Ringing
|
||||
)
|
||||
);
|
||||
|
||||
export const getActiveCall = createSelector(
|
||||
getActiveCallState,
|
||||
getCallsByConversation,
|
||||
(activeCallState, callsByConversation) =>
|
||||
activeCallState &&
|
||||
getOwn(callsByConversation, activeCallState.conversationId)
|
||||
);
|
||||
|
||||
export const isCallActive = createSelector(getActiveCall, Boolean);
|
Loading…
Add table
Add a link
Reference in a new issue