2022-11-11 08:20:33 +00:00
|
|
|
import { IStore } from '../app/types';
|
|
|
|
import { openDialog } from '../base/dialog/actions';
|
2021-06-25 13:28:54 +00:00
|
|
|
|
2022-11-11 08:20:33 +00:00
|
|
|
import PremiumFeatureDialog from './components/web/PremiumFeatureDialog';
|
2021-08-20 08:36:09 +00:00
|
|
|
import { isFeatureDisabled } from './functions';
|
2021-06-25 13:28:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shows a dialog prompting users to upgrade, if requested feature is disabled.
|
|
|
|
*
|
|
|
|
* @param {string} feature - The feature to check availability for.
|
|
|
|
*
|
|
|
|
* @returns {Function}
|
|
|
|
*/
|
|
|
|
export function maybeShowPremiumFeatureDialog(feature: string) {
|
2022-11-11 08:20:33 +00:00
|
|
|
return function(dispatch: IStore['dispatch'], getState: IStore['getState']) {
|
2021-06-25 13:28:54 +00:00
|
|
|
if (isFeatureDisabled(getState(), feature)) {
|
|
|
|
dispatch(openDialog(PremiumFeatureDialog));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}
|