UI: Prevent incorrect bundle loading triggers (#6268)
This commit is contained in:
parent
7902a58075
commit
cd528299ec
@ -8,7 +8,7 @@ import useModuleLoader from '../../../hooks/useModuleLoader';
|
|||||||
|
|
||||||
const FrozenAccountModalAsync: FC<OwnProps> = (props) => {
|
const FrozenAccountModalAsync: FC<OwnProps> = (props) => {
|
||||||
const { modal } = props;
|
const { modal } = props;
|
||||||
const FrozenAccountModal = useModuleLoader(Bundles.Extra, 'FrozenAccountModal', modal);
|
const FrozenAccountModal = useModuleLoader(Bundles.Extra, 'FrozenAccountModal', !modal);
|
||||||
|
|
||||||
return FrozenAccountModal ? <FrozenAccountModal {...props} /> : undefined;
|
return FrozenAccountModal ? <FrozenAccountModal {...props} /> : undefined;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import useModuleLoader from '../../../hooks/useModuleLoader';
|
|||||||
|
|
||||||
const StarPaymentModalAsync: FC<OwnProps> = (props) => {
|
const StarPaymentModalAsync: FC<OwnProps> = (props) => {
|
||||||
const { modal } = props;
|
const { modal } = props;
|
||||||
const StarPaymentModal = useModuleLoader(Bundles.Stars, 'StarPaymentModal', !modal);
|
const StarPaymentModal = useModuleLoader(Bundles.Stars, 'StarPaymentModal', !modal?.inputInvoice);
|
||||||
|
|
||||||
return StarPaymentModal ? <StarPaymentModal {...props} /> : undefined;
|
return StarPaymentModal ? <StarPaymentModal {...props} /> : undefined;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,13 +6,11 @@ import { Bundles } from '../../../util/moduleLoader';
|
|||||||
|
|
||||||
import useModuleLoader from '../../../hooks/useModuleLoader';
|
import useModuleLoader from '../../../hooks/useModuleLoader';
|
||||||
|
|
||||||
import Loading from '../../ui/Loading';
|
|
||||||
|
|
||||||
const SuggestMessageModalAsync: FC<OwnProps> = (props) => {
|
const SuggestMessageModalAsync: FC<OwnProps> = (props) => {
|
||||||
const { modal } = props;
|
const { modal } = props;
|
||||||
const SuggestMessageModal = useModuleLoader(Bundles.Extra, 'SuggestMessageModal', !modal);
|
const SuggestMessageModal = useModuleLoader(Bundles.Extra, 'SuggestMessageModal', !modal);
|
||||||
|
|
||||||
return SuggestMessageModal ? <SuggestMessageModal {...props} /> : <Loading />;
|
return SuggestMessageModal ? <SuggestMessageModal {...props} /> : undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SuggestMessageModalAsync;
|
export default SuggestMessageModalAsync;
|
||||||
|
|||||||
@ -6,13 +6,11 @@ import { Bundles } from '../../../util/moduleLoader';
|
|||||||
|
|
||||||
import useModuleLoader from '../../../hooks/useModuleLoader';
|
import useModuleLoader from '../../../hooks/useModuleLoader';
|
||||||
|
|
||||||
import Loading from '../../ui/Loading';
|
|
||||||
|
|
||||||
const SuggestedPostApprovalModalAsync: FC<OwnProps> = (props) => {
|
const SuggestedPostApprovalModalAsync: FC<OwnProps> = (props) => {
|
||||||
const { modal } = props;
|
const { modal } = props;
|
||||||
const SuggestedPostApprovalModal = useModuleLoader(Bundles.Extra, 'SuggestedPostApprovalModal', !modal);
|
const SuggestedPostApprovalModal = useModuleLoader(Bundles.Extra, 'SuggestedPostApprovalModal', !modal);
|
||||||
|
|
||||||
return SuggestedPostApprovalModal ? <SuggestedPostApprovalModal {...props} /> : <Loading />;
|
return SuggestedPostApprovalModal ? <SuggestedPostApprovalModal {...props} /> : undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SuggestedPostApprovalModalAsync;
|
export default SuggestedPostApprovalModalAsync;
|
||||||
|
|||||||
@ -8,7 +8,7 @@ import useModuleLoader from '../../../hooks/useModuleLoader';
|
|||||||
|
|
||||||
const WebAppModalAsync: FC<OwnProps> = (props) => {
|
const WebAppModalAsync: FC<OwnProps> = (props) => {
|
||||||
const { modal } = props;
|
const { modal } = props;
|
||||||
const WebAppModal = useModuleLoader(Bundles.Extra, 'WebAppModal', !modal);
|
const WebAppModal = useModuleLoader(Bundles.Extra, 'WebAppModal', !modal?.isModalOpen);
|
||||||
|
|
||||||
return WebAppModal ? <WebAppModal {...props} /> : undefined;
|
return WebAppModal ? <WebAppModal {...props} /> : undefined;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { useEffect } from '../lib/teact/teact';
|
|||||||
|
|
||||||
import type { BundleModules, Bundles } from '../util/moduleLoader';
|
import type { BundleModules, Bundles } from '../util/moduleLoader';
|
||||||
|
|
||||||
|
import { DEBUG } from '../config';
|
||||||
import { addLoadListener, getModuleFromMemory, loadModule } from '../util/moduleLoader';
|
import { addLoadListener, getModuleFromMemory, loadModule } from '../util/moduleLoader';
|
||||||
import useForceUpdate from './useForceUpdate';
|
import useForceUpdate from './useForceUpdate';
|
||||||
|
|
||||||
@ -21,6 +22,10 @@ const useModuleLoader = <B extends Bundles, M extends BundleModules<B>>(
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!noLoad && !module) {
|
if (!noLoad && !module) {
|
||||||
|
if (DEBUG) {
|
||||||
|
// eslint-disable-next-line no-console
|
||||||
|
console.log('Module load triggered', bundleName, moduleName);
|
||||||
|
}
|
||||||
loadModule(bundleName).then(forceUpdate);
|
loadModule(bundleName).then(forceUpdate);
|
||||||
}
|
}
|
||||||
}, [bundleName, forceUpdate, module, moduleName, noLoad]);
|
}, [bundleName, forceUpdate, module, moduleName, noLoad]);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user