Close language switcher popup not earlier than locale will be loaded and applied

This commit is contained in:
ErickSkrauch 2020-07-20 00:04:57 +03:00
parent 88c2eab802
commit 7a7d07203e

View File

@ -17,9 +17,11 @@ const LanguageSwitcher: ComponentType<Props> = ({ onClose = () => {} }) => {
const onChangeLang = useCallback( const onChangeLang = useCallback(
(lang: string) => { (lang: string) => {
dispatch(changeLang(lang)); Promise.all([
// TODO: await language change and close popup, but not earlier than after 300ms // 300ms is necessary for the visual animation of the language change to be completed
setTimeout(onClose, 300); new Promise((resolve) => setTimeout(resolve, 300)),
dispatch(changeLang(lang)),
]).then(onClose);
}, },
[dispatch, onClose], [dispatch, onClose],
); );