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