invite: remove duplicated code
Add ability to invite users which will use the share sheet or dialog dynamically.
This commit is contained in:
parent
a7f8bf2d8f
commit
cdc14586de
|
@ -4,13 +4,11 @@ import React, { PureComponent } from 'react';
|
||||||
import { Text, TouchableOpacity, View } from 'react-native';
|
import { Text, TouchableOpacity, View } from 'react-native';
|
||||||
|
|
||||||
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
||||||
import { getFeatureFlag, INVITE_ENABLED } from '../../../base/flags';
|
|
||||||
import { connect } from '../../../base/redux';
|
import { connect } from '../../../base/redux';
|
||||||
import { StyleType } from '../../../base/styles';
|
import { StyleType } from '../../../base/styles';
|
||||||
import { translate } from '../../../base/i18n';
|
import { translate } from '../../../base/i18n';
|
||||||
import { getParticipantCount } from '../../../base/participants';
|
import { getParticipantCount } from '../../../base/participants';
|
||||||
import { isAddPeopleEnabled, isDialOutEnabled, setAddPeopleDialogVisible } from '../../../invite';
|
import { doInvitePeople } from '../../../invite/actions.native';
|
||||||
import { beginShareRoom } from '../../../share-room';
|
|
||||||
|
|
||||||
import styles from './styles';
|
import styles from './styles';
|
||||||
import { Icon, IconAddPeople } from '../../../base/icons';
|
import { Icon, IconAddPeople } from '../../../base/icons';
|
||||||
|
@ -20,11 +18,6 @@ import { Icon, IconAddPeople } from '../../../base/icons';
|
||||||
*/
|
*/
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
||||||
/**
|
|
||||||
* True if any of the invite functions are enabled.
|
|
||||||
*/
|
|
||||||
_inviteEnabled: boolean,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True if it's a lonely meeting (participant count excluding fakes is 1).
|
* True if it's a lonely meeting (participant count excluding fakes is 1).
|
||||||
*/
|
*/
|
||||||
|
@ -112,13 +105,7 @@ class LonelyMeetingExperience extends PureComponent<Props> {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
_onPress() {
|
_onPress() {
|
||||||
const { _inviteEnabled, dispatch } = this.props;
|
this.props.dispatch(doInvitePeople());
|
||||||
|
|
||||||
if (_inviteEnabled) {
|
|
||||||
dispatch(setAddPeopleDialogVisible(true));
|
|
||||||
} else {
|
|
||||||
dispatch(beginShareRoom());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,11 +117,7 @@ class LonelyMeetingExperience extends PureComponent<Props> {
|
||||||
* @returns {Props}
|
* @returns {Props}
|
||||||
*/
|
*/
|
||||||
function _mapStateToProps(state): $Shape<Props> {
|
function _mapStateToProps(state): $Shape<Props> {
|
||||||
const _inviteEnabled = getFeatureFlag(state, INVITE_ENABLED, true)
|
|
||||||
&& (isAddPeopleEnabled(state) || isDialOutEnabled(state));
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
_inviteEnabled,
|
|
||||||
_isLonelyMeeting: getParticipantCount(state) === 1,
|
_isLonelyMeeting: getParticipantCount(state) === 1,
|
||||||
_styles: ColorSchemeRegistry.get(state, 'Conference')
|
_styles: ColorSchemeRegistry.get(state, 'Conference')
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
import type { Dispatch } from 'redux';
|
||||||
|
|
||||||
|
import { getFeatureFlag, INVITE_ENABLED } from '../base/flags';
|
||||||
|
import { beginShareRoom } from '../share-room';
|
||||||
|
|
||||||
|
import { setAddPeopleDialogVisible } from './actions.any';
|
||||||
|
import { isAddPeopleEnabled, isDialOutEnabled } from './functions';
|
||||||
|
|
||||||
|
export * from './actions.any';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the process for inviting people. Dpending on the sysstem config it
|
||||||
|
* may use the system share sheet or the invite peoplee dialog.
|
||||||
|
*
|
||||||
|
* @returns {Function}
|
||||||
|
*/
|
||||||
|
export function doInvitePeople() {
|
||||||
|
return (dispatch: Dispatch<any>, getState: Function) => {
|
||||||
|
const state = getState();
|
||||||
|
const addPeopleEnabled = getFeatureFlag(state, INVITE_ENABLED, true)
|
||||||
|
&& (isAddPeopleEnabled(state) || isDialOutEnabled(state));
|
||||||
|
|
||||||
|
if (addPeopleEnabled) {
|
||||||
|
return dispatch(setAddPeopleDialogVisible(true));
|
||||||
|
}
|
||||||
|
|
||||||
|
return dispatch(beginShareRoom());
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './actions.any';
|
|
@ -24,7 +24,7 @@ import {
|
||||||
} from '../../../../base/react';
|
} from '../../../../base/react';
|
||||||
import { connect } from '../../../../base/redux';
|
import { connect } from '../../../../base/redux';
|
||||||
|
|
||||||
import { setAddPeopleDialogVisible } from '../../../actions';
|
import { setAddPeopleDialogVisible } from '../../../actions.native';
|
||||||
|
|
||||||
import AbstractAddPeopleDialog, {
|
import AbstractAddPeopleDialog, {
|
||||||
type Props as AbstractProps,
|
type Props as AbstractProps,
|
||||||
|
|
|
@ -2,24 +2,16 @@
|
||||||
|
|
||||||
import type { Dispatch } from 'redux';
|
import type { Dispatch } from 'redux';
|
||||||
|
|
||||||
import { getFeatureFlag, INVITE_ENABLED } from '../../../../base/flags';
|
|
||||||
import { translate } from '../../../../base/i18n';
|
import { translate } from '../../../../base/i18n';
|
||||||
import { IconAddPeople } from '../../../../base/icons';
|
import { IconAddPeople } from '../../../../base/icons';
|
||||||
import { connect } from '../../../../base/redux';
|
import { connect } from '../../../../base/redux';
|
||||||
import { AbstractButton } from '../../../../base/toolbox';
|
import { AbstractButton } from '../../../../base/toolbox';
|
||||||
import type { AbstractButtonProps } from '../../../../base/toolbox';
|
import type { AbstractButtonProps } from '../../../../base/toolbox';
|
||||||
import { beginShareRoom } from '../../../../share-room';
|
|
||||||
|
|
||||||
import { setAddPeopleDialogVisible } from '../../../actions';
|
import { doInvitePeople } from '../../../actions.native';
|
||||||
import { isAddPeopleEnabled, isDialOutEnabled } from '../../../functions';
|
|
||||||
|
|
||||||
type Props = AbstractButtonProps & {
|
type Props = AbstractButtonProps & {
|
||||||
|
|
||||||
/**
|
|
||||||
* Whether the (backend) add people feature is enabled or not.
|
|
||||||
*/
|
|
||||||
_addPeopleEnabled: boolean,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Redux dispatch function.
|
* The Redux dispatch function.
|
||||||
*/
|
*/
|
||||||
|
@ -42,31 +34,9 @@ class InviteButton extends AbstractButton<Props, *> {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
_handleClick() {
|
_handleClick() {
|
||||||
const { _addPeopleEnabled, dispatch } = this.props;
|
this.props.dispatch(doInvitePeople());
|
||||||
|
|
||||||
if (_addPeopleEnabled) {
|
|
||||||
dispatch(setAddPeopleDialogVisible(true));
|
|
||||||
} else {
|
|
||||||
dispatch(beginShareRoom());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Maps (parts of) the redux state to {@link InviteButton}'s React {@code Component}
|
|
||||||
* props.
|
|
||||||
*
|
|
||||||
* @param {Object} state - The redux store/state.
|
|
||||||
* @private
|
|
||||||
* @returns {Object}
|
|
||||||
*/
|
|
||||||
function _mapStateToProps(state: Object) {
|
|
||||||
const addPeopleEnabled = getFeatureFlag(state, INVITE_ENABLED, true)
|
|
||||||
&& (isAddPeopleEnabled(state) || isDialOutEnabled(state));
|
|
||||||
|
|
||||||
return {
|
export default translate(connect()(InviteButton));
|
||||||
_addPeopleEnabled: addPeopleEnabled
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default translate(connect(_mapStateToProps)(InviteButton));
|
|
||||||
|
|
|
@ -6,8 +6,8 @@ import Collapsible from 'react-native-collapsible';
|
||||||
|
|
||||||
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
import { ColorSchemeRegistry } from '../../../base/color-scheme';
|
||||||
import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
|
import { BottomSheet, hideDialog, isDialogOpen } from '../../../base/dialog';
|
||||||
import { IconDragHandle } from '../../../base/icons';
|
|
||||||
import { IOS_RECORDING_ENABLED, getFeatureFlag } from '../../../base/flags';
|
import { IOS_RECORDING_ENABLED, getFeatureFlag } from '../../../base/flags';
|
||||||
|
import { IconDragHandle } from '../../../base/icons';
|
||||||
import { connect } from '../../../base/redux';
|
import { connect } from '../../../base/redux';
|
||||||
import { StyleType } from '../../../base/styles';
|
import { StyleType } from '../../../base/styles';
|
||||||
import { SharedDocumentButton } from '../../../etherpad';
|
import { SharedDocumentButton } from '../../../etherpad';
|
||||||
|
|
Loading…
Reference in New Issue