2022-06-16 09:49:07 +00:00
|
|
|
import React, { useCallback } from 'react';
|
2022-04-26 10:15:31 +00:00
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { Platform } from 'react-native';
|
2022-06-16 09:49:07 +00:00
|
|
|
import { useDispatch } from 'react-redux';
|
2022-04-26 10:15:31 +00:00
|
|
|
|
2022-06-21 14:16:38 +00:00
|
|
|
|
2022-06-16 09:49:07 +00:00
|
|
|
import { appNavigate } from '../../app/actions';
|
|
|
|
import {
|
|
|
|
getFeatureFlag,
|
|
|
|
PREJOIN_PAGE_ENABLED
|
|
|
|
} from '../../base/flags';
|
2022-04-26 10:15:31 +00:00
|
|
|
import { IconClose } from '../../base/icons';
|
2022-06-21 14:16:38 +00:00
|
|
|
import { toState } from '../../base/redux';
|
2022-06-16 09:49:07 +00:00
|
|
|
import { cancelKnocking } from '../../lobby/actions.native';
|
2022-04-26 10:15:31 +00:00
|
|
|
|
|
|
|
import HeaderNavigationButton from './components/HeaderNavigationButton';
|
|
|
|
|
2022-06-16 09:49:07 +00:00
|
|
|
|
2022-04-26 10:15:31 +00:00
|
|
|
/**
|
|
|
|
* Close icon/text button based on platform.
|
|
|
|
*
|
|
|
|
* @param {Function} goBack - Goes back to the previous screen function.
|
|
|
|
* @returns {React.Component}
|
|
|
|
*/
|
|
|
|
export function screenHeaderCloseButton(goBack: Function) {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
if (Platform.OS === 'ios') {
|
|
|
|
return (
|
|
|
|
<HeaderNavigationButton
|
|
|
|
label = { t('dialog.close') }
|
|
|
|
onPress = { goBack } />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<HeaderNavigationButton
|
|
|
|
onPress = { goBack }
|
|
|
|
src = { IconClose } />
|
|
|
|
);
|
|
|
|
}
|
2022-06-16 09:49:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determines whether the {@code Prejoin page} is enabled by the app itself
|
|
|
|
* (e.g. Programmatically via the Jitsi Meet SDK for Android and iOS).
|
|
|
|
*
|
|
|
|
* @param {Function|Object} stateful - The redux state or {@link getState}
|
|
|
|
* function.
|
|
|
|
* @returns {boolean} If the {@code Prejoin} is enabled by the app, then
|
|
|
|
* {@code true}; otherwise, {@code false}.
|
|
|
|
*/
|
|
|
|
export function isPrejoinPageEnabled(stateful: Function | Object) {
|
2022-06-21 14:16:38 +00:00
|
|
|
return getFeatureFlag(toState(stateful), PREJOIN_PAGE_ENABLED, true);
|
2022-06-16 09:49:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Close icon/text button for lobby screen based on platform.
|
|
|
|
*
|
|
|
|
* @returns {React.Component}
|
|
|
|
*/
|
|
|
|
export function lobbyScreenHeaderCloseButton() {
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const goBack = useCallback(() => {
|
|
|
|
dispatch(cancelKnocking());
|
|
|
|
dispatch(appNavigate(undefined));
|
|
|
|
}, [ dispatch ]);
|
|
|
|
|
|
|
|
if (Platform.OS === 'ios') {
|
|
|
|
return (
|
|
|
|
<HeaderNavigationButton
|
|
|
|
label = { t('dialog.close') }
|
|
|
|
onPress = { goBack } />
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<HeaderNavigationButton
|
|
|
|
onPress = { goBack }
|
|
|
|
src = { IconClose } />
|
|
|
|
);
|
|
|
|
}
|
2022-06-21 14:16:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if we should auto-knock in case prejoin is enabled for the room.
|
|
|
|
*
|
|
|
|
* @param {Function|Object} stateful - The redux state or {@link getState}
|
|
|
|
* function.
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
export function shouldEnableAutoKnock(stateful: Function | Object) {
|
|
|
|
const state = toState(stateful);
|
|
|
|
const { displayName } = state['features/base/settings'];
|
|
|
|
|
|
|
|
if (isPrejoinPageEnabled(state)) {
|
|
|
|
if (displayName) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|