From 7421ffd1bc52aea1d990d60c5f9ac7e61b97c7aa Mon Sep 17 00:00:00 2001 From: xmflsct Date: Sat, 3 Dec 2022 21:56:52 +0100 Subject: [PATCH] Fix toot relative time does not align with app's language --- src/App.tsx | 26 ++++++++++++++------------ src/Screens.tsx | 5 ++--- src/components/RelativeTime.tsx | 2 +- src/startup/timezone.ts | 4 ++-- 4 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 2f26fdb8..6575b3e1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,5 +1,4 @@ import { ActionSheetProvider } from '@expo/react-native-action-sheet' -import getLanguage from '@helpers/getLanguage' import queryClient from '@helpers/queryClient' import i18n from '@root/i18n/i18n' import Screens from '@root/Screens' @@ -13,11 +12,12 @@ import timezone from '@root/startup/timezone' import { persistor, store } from '@root/store' import * as Sentry from '@sentry/react-native' import AccessibilityManager from '@utils/accessibility/AccessibilityManager' -import { changeLanguage } from '@utils/slices/settingsSlice' +import { changeLanguage, getSettingsLanguage } from '@utils/slices/settingsSlice' import ThemeManager from '@utils/styles/ThemeManager' import * as Localization from 'expo-localization' import * as SplashScreen from 'expo-splash-screen' import React, { useCallback, useEffect, useState } from 'react' +import { IntlProvider } from 'react-intl' import { LogBox, Platform } from 'react-native' import { GestureHandlerRootView } from 'react-native-gesture-handler' import { SafeAreaProvider } from 'react-native-safe-area-context' @@ -85,7 +85,7 @@ const App: React.FC = () => { if (bootstrapped) { log('log', 'App', 'loading actual app :)') log('log', 'App', `Locale: ${Localization.locale}`) - const language = getLanguage() + const language = getSettingsLanguage(store.getState()) if (!language) { if (Platform.OS !== 'ios') { store.dispatch(changeLanguage('en')) @@ -96,15 +96,17 @@ const App: React.FC = () => { } return ( - - - - - - - - - + + + + + + + + + + + ) } else { return null diff --git a/src/Screens.tsx b/src/Screens.tsx index 59c7c3b1..c88da00b 100644 --- a/src/Screens.tsx +++ b/src/Screens.tsx @@ -27,7 +27,6 @@ import * as Linking from 'expo-linking' import { addScreenshotListener } from 'expo-screen-capture' import React, { useCallback, useEffect, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' -import { IntlProvider } from 'react-intl' import { Alert, Platform, StatusBar } from 'react-native' import ShareMenu from 'react-native-share-menu' import { useSelector } from 'react-redux' @@ -271,7 +270,7 @@ const Screens: React.FC = ({ localCorrupt }) => { }, []) return ( - + <> = ({ localCorrupt }) => { - + ) } diff --git a/src/components/RelativeTime.tsx b/src/components/RelativeTime.tsx index 5b1589f4..25a7a2db 100644 --- a/src/components/RelativeTime.tsx +++ b/src/components/RelativeTime.tsx @@ -9,7 +9,7 @@ export interface Props { const RelativeTime: React.FC = ({ time }) => { const [now, setNow] = useState(new Date().getTime()) useEffect(() => { - const appStateListener = AppState.addEventListener('change', state => { + const appStateListener = AppState.addEventListener('change', () => { setNow(new Date().getTime()) }) diff --git a/src/startup/timezone.ts b/src/startup/timezone.ts index dd466588..d0a8f439 100644 --- a/src/startup/timezone.ts +++ b/src/startup/timezone.ts @@ -2,10 +2,10 @@ import * as Localization from 'expo-localization' import log from './log' const timezone = () => { - log('log', 'Timezone', Localization.timezone) + log('log', 'Timezone', Localization.getCalendars()[0].timeZone || 'unknown') if ('__setDefaultTimeZone' in Intl.DateTimeFormat) { // @ts-ignore - Intl.DateTimeFormat.__setDefaultTimeZone(Localization.timezone) + Intl.DateTimeFormat.__setDefaultTimeZone(Localization.getCalendars()[0].timeZone) } }