2022-10-20 12:11:27 +03:00
|
|
|
import { IReduxState } from '../../app/types';
|
2023-04-18 13:55:31 -04:00
|
|
|
import JitsiMeetJS from '../../base/lib-jitsi-meet';
|
2023-07-20 13:25:40 +03:00
|
|
|
import { NOTIFY_CLICK_MODE } from '../../toolbox/constants';
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
IConfig,
|
|
|
|
|
IDeeplinkingConfig,
|
|
|
|
|
IDeeplinkingMobileConfig,
|
|
|
|
|
IDeeplinkingPlatformConfig,
|
2023-08-14 09:45:07 +03:00
|
|
|
NotifyClickButton,
|
|
|
|
|
ToolbarButton
|
2023-07-20 13:25:40 +03:00
|
|
|
} from './configType';
|
2021-03-10 17:39:35 +02:00
|
|
|
import { TOOLBAR_BUTTONS } from './constants';
|
|
|
|
|
|
2019-04-30 12:24:12 +02:00
|
|
|
export * from './functions.any';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes all analytics related options from the given configuration, in case of a libre build.
|
|
|
|
|
*
|
2022-12-20 19:03:57 +02:00
|
|
|
* @param {*} _config - The configuration which needs to be cleaned up.
|
2019-04-30 12:24:12 +02:00
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
2022-12-20 19:03:57 +02:00
|
|
|
export function _cleanupConfig(_config: IConfig) {
|
|
|
|
|
return;
|
2019-04-30 12:24:12 +02:00
|
|
|
}
|
2020-05-14 15:30:24 +03:00
|
|
|
|
2021-06-16 14:08:18 +03:00
|
|
|
/**
|
|
|
|
|
* Returns the replaceParticipant config.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
2022-10-20 12:11:27 +03:00
|
|
|
export function getReplaceParticipant(state: IReduxState): string | undefined {
|
2021-06-16 14:08:18 +03:00
|
|
|
return state['features/base/config'].replaceParticipant;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-10 17:39:35 +02:00
|
|
|
/**
|
|
|
|
|
* Returns the list of enabled toolbar buttons.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The redux state.
|
|
|
|
|
* @returns {Array<string>} - The list of enabled toolbar buttons.
|
|
|
|
|
*/
|
2022-10-20 12:11:27 +03:00
|
|
|
export function getToolbarButtons(state: IReduxState): Array<string> {
|
2023-02-09 13:12:00 +02:00
|
|
|
const { toolbarButtons, customToolbarButtons } = state['features/base/config'];
|
|
|
|
|
const customButtons = customToolbarButtons?.map(({ id }) => id);
|
2021-03-10 17:39:35 +02:00
|
|
|
|
2023-02-09 13:12:00 +02:00
|
|
|
const buttons = Array.isArray(toolbarButtons) ? toolbarButtons : TOOLBAR_BUTTONS;
|
|
|
|
|
|
|
|
|
|
if (customButtons) {
|
2023-08-14 09:45:07 +03:00
|
|
|
buttons.push(...customButtons as ToolbarButton[]);
|
2023-02-09 13:12:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buttons;
|
2021-03-10 17:39:35 +02:00
|
|
|
}
|
2021-05-13 09:56:53 +03:00
|
|
|
|
2023-03-17 10:24:29 +02:00
|
|
|
/**
|
|
|
|
|
* Returns the configuration value of web-hid feature.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
|
* @returns {boolean} True if web-hid feature should be enabled, otherwise false.
|
|
|
|
|
*/
|
|
|
|
|
export function getWebHIDFeatureConfig(state: IReduxState): boolean {
|
|
|
|
|
return state['features/base/config'].enableWebHIDFeature || false;
|
|
|
|
|
}
|
|
|
|
|
|
2021-05-13 09:56:53 +03:00
|
|
|
/**
|
2021-07-09 07:36:19 -05:00
|
|
|
* Checks if the specified button is enabled.
|
2021-05-13 09:56:53 +03:00
|
|
|
*
|
|
|
|
|
* @param {string} buttonName - The name of the button.
|
|
|
|
|
* {@link interfaceConfig}.
|
2021-07-09 07:36:19 -05:00
|
|
|
* @param {Object|Array<string>} state - The redux state or the array with the enabled buttons.
|
|
|
|
|
* @returns {boolean} - True if the button is enabled and false otherwise.
|
2021-05-13 09:56:53 +03:00
|
|
|
*/
|
2022-10-20 12:11:27 +03:00
|
|
|
export function isToolbarButtonEnabled(buttonName: string, state: IReduxState | Array<string>) {
|
2021-07-09 07:36:19 -05:00
|
|
|
const buttons = Array.isArray(state) ? state : getToolbarButtons(state);
|
|
|
|
|
|
|
|
|
|
return buttons.includes(buttonName);
|
|
|
|
|
}
|
2022-01-11 11:08:36 -05:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns whether audio level measurement is enabled or not.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The state of the app.
|
|
|
|
|
* @returns {boolean}
|
|
|
|
|
*/
|
2022-10-20 12:11:27 +03:00
|
|
|
export function areAudioLevelsEnabled(state: IReduxState): boolean {
|
2023-04-18 13:55:31 -04:00
|
|
|
return !state['features/base/config'].disableAudioLevels && JitsiMeetJS.isCollectingLocalStats();
|
2022-01-11 11:08:36 -05:00
|
|
|
}
|
2022-12-20 19:03:57 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the defaults for deeplinking.
|
|
|
|
|
*
|
|
|
|
|
* @param {IDeeplinkingConfig} deeplinking - The deeplinking config.
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
export function _setDeeplinkingDefaults(deeplinking: IDeeplinkingConfig) {
|
|
|
|
|
const {
|
|
|
|
|
desktop = {} as IDeeplinkingPlatformConfig,
|
|
|
|
|
android = {} as IDeeplinkingMobileConfig,
|
|
|
|
|
ios = {} as IDeeplinkingMobileConfig
|
|
|
|
|
} = deeplinking;
|
|
|
|
|
|
|
|
|
|
desktop.appName = desktop.appName || 'Jitsi Meet';
|
|
|
|
|
|
|
|
|
|
ios.appName = ios.appName || 'Jitsi Meet';
|
|
|
|
|
ios.appScheme = ios.appScheme || 'org.jitsi.meet';
|
|
|
|
|
ios.downloadLink = ios.downloadLink
|
|
|
|
|
|| 'https://itunes.apple.com/us/app/jitsi-meet/id1165103905';
|
|
|
|
|
if (ios.dynamicLink) {
|
|
|
|
|
ios.dynamicLink.apn = ios.dynamicLink.apn || 'org.jitsi.meet';
|
|
|
|
|
ios.dynamicLink.appCode = ios.dynamicLink.appCode || 'w2atb';
|
|
|
|
|
ios.dynamicLink.ibi = ios.dynamicLink.ibi || 'com.atlassian.JitsiMeet.ios';
|
|
|
|
|
ios.dynamicLink.isi = ios.dynamicLink.isi || '1165103905';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
android.appName = android.appName || 'Jitsi Meet';
|
|
|
|
|
android.appScheme = android.appScheme || 'org.jitsi.meet';
|
|
|
|
|
android.downloadLink = android.downloadLink
|
|
|
|
|
|| 'https://play.google.com/store/apps/details?id=org.jitsi.meet';
|
|
|
|
|
android.appPackage = android.appPackage || 'org.jitsi.meet';
|
|
|
|
|
android.fDroidUrl = android.fDroidUrl || 'https://f-droid.org/en/packages/org.jitsi.meet/';
|
|
|
|
|
if (android.dynamicLink) {
|
|
|
|
|
android.dynamicLink.apn = android.dynamicLink.apn || 'org.jitsi.meet';
|
|
|
|
|
android.dynamicLink.appCode = android.dynamicLink.appCode || 'w2atb';
|
|
|
|
|
android.dynamicLink.ibi = android.dynamicLink.ibi || 'com.atlassian.JitsiMeet.ios';
|
|
|
|
|
android.dynamicLink.isi = android.dynamicLink.isi || '1165103905';
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-09 13:12:00 +02:00
|
|
|
|
|
|
|
|
/**
|
2023-07-20 13:25:40 +03:00
|
|
|
* Common logic to gather buttons that have to notify the api when clicked.
|
2023-02-09 13:12:00 +02:00
|
|
|
*
|
2023-07-20 13:25:40 +03:00
|
|
|
* @param {Array} buttonsWithNotifyClick - The array of systme buttons that need to notify the api.
|
|
|
|
|
* @param {Array} customButtons - The custom buttons.
|
|
|
|
|
* @returns {Array}
|
2023-02-09 13:12:00 +02:00
|
|
|
*/
|
2023-07-20 13:25:40 +03:00
|
|
|
const buildButtonsArray = (
|
|
|
|
|
buttonsWithNotifyClick?: NotifyClickButton[],
|
|
|
|
|
customButtons?: {
|
|
|
|
|
icon: string;
|
|
|
|
|
id: string;
|
|
|
|
|
text: string;
|
|
|
|
|
}[]
|
|
|
|
|
): NotifyClickButton[] => {
|
|
|
|
|
const customButtonsWithNotifyClick = customButtons?.map(({ id }) => {
|
2023-02-09 13:12:00 +02:00
|
|
|
return {
|
|
|
|
|
key: id,
|
|
|
|
|
preventExecution: false
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const buttons = Array.isArray(buttonsWithNotifyClick)
|
2023-07-20 13:25:40 +03:00
|
|
|
? buttonsWithNotifyClick as NotifyClickButton[]
|
2023-02-09 13:12:00 +02:00
|
|
|
: [];
|
|
|
|
|
|
2023-07-20 13:25:40 +03:00
|
|
|
if (customButtonsWithNotifyClick) {
|
|
|
|
|
buttons.push(...customButtonsWithNotifyClick);
|
2023-02-09 13:12:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return buttons;
|
2023-07-20 13:25:40 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the list of toolbar buttons that have to notify the api when clicked.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The redux state.
|
|
|
|
|
* @returns {Array} - The list of buttons.
|
|
|
|
|
*/
|
|
|
|
|
export function getButtonsWithNotifyClick(
|
|
|
|
|
state: IReduxState
|
|
|
|
|
): NotifyClickButton[] {
|
|
|
|
|
const { buttonsWithNotifyClick, customToolbarButtons } = state['features/base/config'];
|
|
|
|
|
|
|
|
|
|
return buildButtonsArray(
|
|
|
|
|
buttonsWithNotifyClick,
|
|
|
|
|
customToolbarButtons
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns the list of participant menu buttons that have that notify the api when clicked.
|
|
|
|
|
*
|
|
|
|
|
* @param {Object} state - The redux state.
|
|
|
|
|
* @returns {Array} - The list of participant menu buttons.
|
|
|
|
|
*/
|
|
|
|
|
export function getParticipantMenuButtonsWithNotifyClick(
|
|
|
|
|
state: IReduxState
|
|
|
|
|
): NotifyClickButton[] {
|
|
|
|
|
const { participantMenuButtonsWithNotifyClick, customParticipantMenuButtons } = state['features/base/config'];
|
|
|
|
|
|
|
|
|
|
return buildButtonsArray(
|
|
|
|
|
participantMenuButtonsWithNotifyClick,
|
|
|
|
|
customParticipantMenuButtons
|
|
|
|
|
);
|
2023-02-09 13:12:00 +02:00
|
|
|
}
|
|
|
|
|
|
2023-07-20 13:25:40 +03:00
|
|
|
/**
|
|
|
|
|
* Returns the notify mode for the specified button.
|
|
|
|
|
*
|
|
|
|
|
* @param {string} buttonKey - The button key.
|
|
|
|
|
* @param {Array} buttonsWithNotifyClick - The buttons with notify click.
|
|
|
|
|
* @returns {string|undefined}
|
|
|
|
|
*/
|
|
|
|
|
export const getButtonNotifyMode = (
|
|
|
|
|
buttonKey: string,
|
|
|
|
|
buttonsWithNotifyClick?: NotifyClickButton[]
|
|
|
|
|
): string | undefined => {
|
|
|
|
|
const notify = buttonsWithNotifyClick?.find(
|
|
|
|
|
(btn: NotifyClickButton) =>
|
|
|
|
|
(typeof btn === 'string' && btn === buttonKey) || (typeof btn === 'object' && btn.key === buttonKey)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (notify) {
|
|
|
|
|
return typeof notify === 'string' || notify.preventExecution
|
|
|
|
|
? NOTIFY_CLICK_MODE.PREVENT_AND_NOTIFY
|
|
|
|
|
: NOTIFY_CLICK_MODE.ONLY_NOTIFY;
|
|
|
|
|
}
|
|
|
|
|
};
|