From da55abed8f4ec89d9fc96651124b04c862d98128 Mon Sep 17 00:00:00 2001 From: Arnaud Vergnet Date: Wed, 23 Sep 2020 09:08:47 +0200 Subject: [PATCH] Fix proxiwash translations not loading --- .../Lists/Proxiwash/ProxiwashListItem.tsx | 26 +++++++++---------- src/screens/Proxiwash/ProxiwashScreen.tsx | 26 +++++++++---------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/components/Lists/Proxiwash/ProxiwashListItem.tsx b/src/components/Lists/Proxiwash/ProxiwashListItem.tsx index 0845128..2317805 100644 --- a/src/components/Lists/Proxiwash/ProxiwashListItem.tsx +++ b/src/components/Lists/Proxiwash/ProxiwashListItem.tsx @@ -67,22 +67,22 @@ const styles = StyleSheet.create({ }, }); -const stateStrings: {[key in MachineStates]: string} = { - [MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.states.ready'), - [MachineStates.RUNNING]: i18n.t('screens.proxiwash.states.running'), - [MachineStates.RUNNING_NOT_STARTED]: i18n.t( - 'screens.proxiwash.states.runningNotStarted', - ), - [MachineStates.FINISHED]: i18n.t('screens.proxiwash.states.finished'), - [MachineStates.UNAVAILABLE]: i18n.t('screens.proxiwash.states.broken'), - [MachineStates.ERROR]: i18n.t('screens.proxiwash.states.error'), - [MachineStates.UNKNOWN]: i18n.t('screens.proxiwash.states.unknown'), -}; - /** * Component used to display a proxiwash item, showing machine progression and state */ class ProxiwashListItem extends React.Component { + static stateStrings: {[key in MachineStates]: string} = { + [MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.states.ready'), + [MachineStates.RUNNING]: i18n.t('screens.proxiwash.states.running'), + [MachineStates.RUNNING_NOT_STARTED]: i18n.t( + 'screens.proxiwash.states.runningNotStarted', + ), + [MachineStates.FINISHED]: i18n.t('screens.proxiwash.states.finished'), + [MachineStates.UNAVAILABLE]: i18n.t('screens.proxiwash.states.broken'), + [MachineStates.ERROR]: i18n.t('screens.proxiwash.states.error'), + [MachineStates.UNKNOWN]: i18n.t('screens.proxiwash.states.unknown'), + }; + stateColors: {[key: string]: string}; title: string; @@ -146,7 +146,7 @@ class ProxiwashListItem extends React.Component { ? `${props.item.startTime}/${props.item.endTime}` : ''; const stateIcon = ProxiwashConstants.stateIcons[machineState]; - const stateString = stateStrings[machineState]; + const stateString = ProxiwashListItem.stateStrings[machineState]; let progress; if (isRunning && props.item.donePercent !== '') { progress = parseFloat(props.item.donePercent) / 100; diff --git a/src/screens/Proxiwash/ProxiwashScreen.tsx b/src/screens/Proxiwash/ProxiwashScreen.tsx index bbbb679..fd35027 100644 --- a/src/screens/Proxiwash/ProxiwashScreen.tsx +++ b/src/screens/Proxiwash/ProxiwashScreen.tsx @@ -46,18 +46,6 @@ import MascotPopup from '../../components/Mascot/MascotPopup'; import type {SectionListDataType} from '../../components/Screens/WebSectionList'; import type {LaundromatType} from './ProxiwashAboutScreen'; -const modalStateStrings: {[key in MachineStates]: string} = { - [MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.modal.ready'), - [MachineStates.RUNNING]: i18n.t('screens.proxiwash.modal.running'), - [MachineStates.RUNNING_NOT_STARTED]: i18n.t( - 'screens.proxiwash.modal.runningNotStarted', - ), - [MachineStates.FINISHED]: i18n.t('screens.proxiwash.modal.finished'), - [MachineStates.UNAVAILABLE]: i18n.t('screens.proxiwash.modal.broken'), - [MachineStates.ERROR]: i18n.t('screens.proxiwash.modal.error'), - [MachineStates.UNKNOWN]: i18n.t('screens.proxiwash.modal.unknown'), -}; - const REFRESH_TIME = 1000 * 10; // Refresh every 10 seconds const LIST_ITEM_HEIGHT = 64; @@ -98,6 +86,18 @@ class ProxiwashScreen extends React.Component { ); } + static modalStateStrings: {[key in MachineStates]: string} = { + [MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.modal.ready'), + [MachineStates.RUNNING]: i18n.t('screens.proxiwash.modal.running'), + [MachineStates.RUNNING_NOT_STARTED]: i18n.t( + 'screens.proxiwash.modal.runningNotStarted', + ), + [MachineStates.FINISHED]: i18n.t('screens.proxiwash.modal.finished'), + [MachineStates.UNAVAILABLE]: i18n.t('screens.proxiwash.modal.broken'), + [MachineStates.ERROR]: i18n.t('screens.proxiwash.modal.error'), + [MachineStates.UNKNOWN]: i18n.t('screens.proxiwash.modal.unknown'), + }; + modalRef: null | Modalize; fetchedData: { @@ -205,7 +205,7 @@ class ProxiwashScreen extends React.Component { icon: '', onPress: () => undefined, }; - let message = modalStateStrings[item.state]; + let message = ProxiwashScreen.modalStateStrings[item.state]; const onPress = () => this.onSetupNotificationsPress(item); if (item.state === MachineStates.RUNNING) { let remainingTime = parseInt(item.remainingTime, 10);