init
Some checks failed
Close stale issues and PRs / stale (push) Has been cancelled

This commit is contained in:
2025-09-02 14:49:16 +08:00
commit 38ba663466
2885 changed files with 391107 additions and 0 deletions

View 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';

View 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
};
}

View 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
};
}

View File

@@ -0,0 +1,3 @@
import { getLogger } from '../base/logging/functions';
export default getLogger('features/share-room');

View 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));
});
});
}

View 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;
});