From 51a5b391291be3c0a7e8c16520dca9cb86d100df Mon Sep 17 00:00:00 2001 From: Paulo Gustavo Veiga Date: Sat, 19 Nov 2022 11:58:43 -0800 Subject: [PATCH] Add change location workaround. --- .../maps-page/language-menu/index.tsx | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/webapp/src/components/maps-page/language-menu/index.tsx b/packages/webapp/src/components/maps-page/language-menu/index.tsx index 46f6b00e..517cb80c 100644 --- a/packages/webapp/src/components/maps-page/language-menu/index.tsx +++ b/packages/webapp/src/components/maps-page/language-menu/index.tsx @@ -26,15 +26,19 @@ const LanguageMenu = (): React.ReactElement => { const open = Boolean(anchorEl); const intl = useIntl(); - const mutation = useMutation((locale: LocaleCode) => client.updateAccountLanguage(locale), { - onSuccess: () => { - queryClient.invalidateQueries('account'); - handleClose(); + // Todo: For some reasons, in some situations locale is null. More research needed. + const mutation = useMutation( + (locale: LocaleCode) => client.updateAccountLanguage(locale ? locale : 'en'), + { + onSuccess: () => { + queryClient.invalidateQueries('account'); + handleClose(); + }, + onError: (error) => { + console.error(`Unexpected error ${error}`); + }, }, - onError: (error) => { - console.error(`Unexpected error ${error}`); - }, - }); + ); const handleMenu = (event: React.MouseEvent) => { setAnchorEl(event.currentTarget);