This commit is contained in:
33
react/features/share-room/actionTypes.ts
Normal file
33
react/features/share-room/actionTypes.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
* The type of (redux) action which begins the UI procedure to share the current
|
||||
* conference/room URL.
|
||||
*
|
||||
* {
|
||||
* type: BEGIN_SHARE_ROOM,
|
||||
* roomURL: string,
|
||||
* includeDialInfo: boolean
|
||||
* }
|
||||
*/
|
||||
export const BEGIN_SHARE_ROOM = 'BEGIN_SHARE_ROOM';
|
||||
|
||||
/**
|
||||
* The type of (redux) action which ends the UI procedure to share a specific
|
||||
* conference/room URL.
|
||||
*
|
||||
* {
|
||||
* type: END_SHARE_ROOM,
|
||||
* roomURL: string,
|
||||
* shared: boolean
|
||||
* }
|
||||
*/
|
||||
export const END_SHARE_ROOM = 'END_SHARE_ROOM';
|
||||
|
||||
/**
|
||||
* The type of (redux) action which toggles the share meeting url dialog visibility.
|
||||
*
|
||||
* {
|
||||
* type: TOGGLE_SHARE_DIALOG,
|
||||
* visible: boolean
|
||||
* }
|
||||
*/
|
||||
export const TOGGLE_SHARE_DIALOG = 'TOGGLE_SHARE_DIALOG';
|
||||
69
react/features/share-room/actions.ts
Normal file
69
react/features/share-room/actions.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import { IStore } from '../app/types';
|
||||
import { getInviteURL } from '../base/connection/functions';
|
||||
|
||||
import {
|
||||
BEGIN_SHARE_ROOM,
|
||||
END_SHARE_ROOM,
|
||||
TOGGLE_SHARE_DIALOG
|
||||
} from './actionTypes';
|
||||
|
||||
/**
|
||||
* Begins the UI procedure to share the URL for the current conference/room.
|
||||
*
|
||||
* @param {string} roomURL - The URL of the room to share.
|
||||
* @public
|
||||
* @returns {Function}
|
||||
*/
|
||||
export function beginShareRoom(roomURL?: string) {
|
||||
return (dispatch: IStore['dispatch'], getState: IStore['getState']) => {
|
||||
if (!roomURL) {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
roomURL = getInviteURL(getState);
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: BEGIN_SHARE_ROOM,
|
||||
roomURL
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the UI procedure to share a specific conference/room URL.
|
||||
*
|
||||
* @param {string} roomURL - The URL of the conference/room which was shared.
|
||||
* @param {boolean} shared - True if the URL was shared successfully; false,
|
||||
* otherwise.
|
||||
* @public
|
||||
* @returns {{
|
||||
* type: END_SHARE_ROOM,
|
||||
* roomURL: string,
|
||||
* shared: boolean
|
||||
* }}
|
||||
*/
|
||||
export function endShareRoom(roomURL: string, shared: boolean) {
|
||||
return {
|
||||
type: END_SHARE_ROOM,
|
||||
roomURL,
|
||||
shared
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* UI procedure for sharing conference room URL inside a dialog.
|
||||
*
|
||||
* @param {boolean} visible - True if share dialog is visible; false,
|
||||
* otherwise.
|
||||
* @public
|
||||
* @returns {{
|
||||
* type: TOGGLE_SHARE_DIALOG,
|
||||
* visible: boolean
|
||||
* }}
|
||||
*/
|
||||
export function toggleShareDialog(visible: boolean) {
|
||||
return {
|
||||
type: TOGGLE_SHARE_DIALOG,
|
||||
visible
|
||||
};
|
||||
}
|
||||
18
react/features/share-room/functions.ts
Normal file
18
react/features/share-room/functions.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { IReduxState } from '../app/types';
|
||||
import BaseTheme from '../base/ui/components/BaseTheme.native';
|
||||
|
||||
/**
|
||||
* Control for invite others button enabling.
|
||||
*
|
||||
* @param {IReduxState} state - State object.
|
||||
* @returns {Object}
|
||||
*/
|
||||
export function getInviteOthersControl(state: IReduxState) {
|
||||
const { shareDialogVisible } = state['features/share-room'];
|
||||
const { icon01, icon03 } = BaseTheme.palette;
|
||||
|
||||
return {
|
||||
color: shareDialogVisible ? icon03 : icon01,
|
||||
shareDialogVisible
|
||||
};
|
||||
}
|
||||
3
react/features/share-room/logger.ts
Normal file
3
react/features/share-room/logger.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import { getLogger } from '../base/logging/functions';
|
||||
|
||||
export default getLogger('features/share-room');
|
||||
71
react/features/share-room/middleware.ts
Normal file
71
react/features/share-room/middleware.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
import { Share } from 'react-native';
|
||||
|
||||
import { getName } from '../app/functions.native';
|
||||
import { IStore } from '../app/types';
|
||||
import { INVITE_DIAL_IN_ENABLED } from '../base/flags/constants';
|
||||
import { getFeatureFlag } from '../base/flags/functions';
|
||||
import MiddlewareRegistry from '../base/redux/MiddlewareRegistry';
|
||||
import { getShareInfoText } from '../invite/functions';
|
||||
|
||||
import { BEGIN_SHARE_ROOM } from './actionTypes';
|
||||
import { endShareRoom, toggleShareDialog } from './actions';
|
||||
import logger from './logger';
|
||||
|
||||
/**
|
||||
* Middleware that captures room URL sharing actions and starts the sharing
|
||||
* process.
|
||||
*
|
||||
* @param {Store} store - Redux store.
|
||||
* @returns {Function}
|
||||
*/
|
||||
MiddlewareRegistry.register(store => next => action => {
|
||||
switch (action.type) {
|
||||
case BEGIN_SHARE_ROOM:
|
||||
_shareRoom(action.roomURL, store);
|
||||
break;
|
||||
}
|
||||
|
||||
return next(action);
|
||||
});
|
||||
|
||||
/**
|
||||
* Open the native sheet for sharing a specific conference/room URL.
|
||||
*
|
||||
* @param {string} roomURL - The URL of the conference/room to be shared.
|
||||
* @param {Store} store - Redux store.
|
||||
* @private
|
||||
* @returns {void}
|
||||
*/
|
||||
function _shareRoom(roomURL: string, { dispatch, getState }: IStore) {
|
||||
const dialInEnabled = getFeatureFlag(getState(), INVITE_DIAL_IN_ENABLED, true);
|
||||
|
||||
getShareInfoText(getState(), roomURL, false /* useHtml */, !dialInEnabled /* skipDialIn */)
|
||||
.then(message => {
|
||||
const title = `${getName()} Conference`;
|
||||
const onFulfilled
|
||||
= (shared: boolean) => dispatch(endShareRoom(roomURL, shared));
|
||||
|
||||
Share.share(
|
||||
/* content */ {
|
||||
message,
|
||||
title
|
||||
},
|
||||
/* options */ {
|
||||
dialogTitle: title, // Android
|
||||
subject: title // iOS
|
||||
})
|
||||
.then(
|
||||
/* onFulfilled */ value => {
|
||||
onFulfilled(value.action === Share.sharedAction);
|
||||
},
|
||||
/* onRejected */ reason => {
|
||||
logger.error(
|
||||
`Failed to share conference/room URL ${roomURL}:`,
|
||||
reason);
|
||||
onFulfilled(false);
|
||||
})
|
||||
.finally(() => {
|
||||
dispatch(toggleShareDialog(false));
|
||||
});
|
||||
});
|
||||
}
|
||||
23
react/features/share-room/reducer.ts
Normal file
23
react/features/share-room/reducer.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import ReducerRegistry from '../base/redux/ReducerRegistry';
|
||||
|
||||
import { TOGGLE_SHARE_DIALOG } from './actionTypes';
|
||||
|
||||
const DEFAULT_STATE = {
|
||||
shareDialogVisible: false
|
||||
};
|
||||
|
||||
export interface IShareRoomState {
|
||||
shareDialogVisible: boolean;
|
||||
}
|
||||
|
||||
ReducerRegistry.register<IShareRoomState>('features/share-room', (state = DEFAULT_STATE, action): IShareRoomState => {
|
||||
switch (action.type) {
|
||||
case TOGGLE_SHARE_DIALOG:
|
||||
return {
|
||||
...state,
|
||||
shareDialogVisible: action.visible
|
||||
};
|
||||
}
|
||||
|
||||
return state;
|
||||
});
|
||||
Reference in New Issue
Block a user