mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-05-08 08:58:38 +01:00
Redux state: Allow multiple calls to be stored
This commit is contained in:
@@ -5,7 +5,8 @@ import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { mapDispatchToProps } from '../actions';
|
||||
import { CallManager } from '../../components/CallManager';
|
||||
import { getMe } from '../selectors/conversations';
|
||||
import { getMe, getConversationSelector } from '../selectors/conversations';
|
||||
import { getActiveCall, getIncomingCall } from '../selectors/calling';
|
||||
import { StateType } from '../reducer';
|
||||
|
||||
import { getIntl } from '../selectors/user';
|
||||
@@ -16,16 +17,64 @@ function renderDeviceSelection(): JSX.Element {
|
||||
return <SmartCallingDeviceSelection />;
|
||||
}
|
||||
|
||||
const mapStateToProps = (state: StateType) => {
|
||||
const mapStateToActiveCallProp = (state: StateType) => {
|
||||
const { calling } = state;
|
||||
const { activeCallState } = calling;
|
||||
|
||||
if (!activeCallState) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const call = getActiveCall(calling);
|
||||
if (!call) {
|
||||
window.log.error(
|
||||
'There was an active call state but no corresponding call'
|
||||
);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const conversation = getConversationSelector(state)(
|
||||
activeCallState.conversationId
|
||||
);
|
||||
if (!conversation) {
|
||||
window.log.error('The active call has no corresponding conversation');
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
...calling,
|
||||
i18n: getIntl(state),
|
||||
me: getMe(state),
|
||||
renderDeviceSelection,
|
||||
call,
|
||||
activeCallState,
|
||||
conversation,
|
||||
};
|
||||
};
|
||||
|
||||
const mapStateToIncomingCallProp = (state: StateType) => {
|
||||
const call = getIncomingCall(state.calling);
|
||||
if (!call) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const conversation = getConversationSelector(state)(call.conversationId);
|
||||
if (!conversation) {
|
||||
window.log.error('The incoming call has no corresponding conversation');
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return {
|
||||
call,
|
||||
conversation,
|
||||
};
|
||||
};
|
||||
|
||||
const mapStateToProps = (state: StateType) => ({
|
||||
activeCall: mapStateToActiveCallProp(state),
|
||||
availableCameras: state.calling.availableCameras,
|
||||
i18n: getIntl(state),
|
||||
incomingCall: mapStateToIncomingCallProp(state),
|
||||
me: getMe(state),
|
||||
renderDeviceSelection,
|
||||
});
|
||||
|
||||
const smart = connect(mapStateToProps, mapDispatchToProps);
|
||||
|
||||
export const SmartCallManager = smart(CallManager);
|
||||
|
||||
Reference in New Issue
Block a user