Compare commits

...

3 commits

Author SHA1 Message Date
Arnaud Vergnet
fe96d9f8a1 fix proxiwash change not auto refreshing list 2021-05-22 18:38:10 +02:00
Arnaud Vergnet
44d35090ac Add token retrieve error 2021-05-22 18:23:29 +02:00
Arnaud Vergnet
245e6c5cc8 Remove log 2021-05-22 15:45:56 +02:00
7 changed files with 21 additions and 10 deletions

View file

@ -463,6 +463,7 @@
"badToken": "You are not logged in. Please login and try again.", "badToken": "You are not logged in. Please login and try again.",
"noConsent": "You did not give your consent for data processing to the Amicale.", "noConsent": "You did not give your consent for data processing to the Amicale.",
"tokenSave": "Could not save session token. Please contact support.", "tokenSave": "Could not save session token. Please contact support.",
"tokenRetrieve": "Could not retrieve session token. Please contact support.",
"badInput": "Invalid input. Please try again.", "badInput": "Invalid input. Please try again.",
"forbidden": "You do not have access to this data.", "forbidden": "You do not have access to this data.",
"connectionError": "Network error. Please check your internet connection.", "connectionError": "Network error. Please check your internet connection.",

View file

@ -463,6 +463,7 @@
"badToken": "Tu n'est pas connecté. Merci de te connecter puis réessayes.", "badToken": "Tu n'est pas connecté. Merci de te connecter puis réessayes.",
"noConsent": "Tu n'as pas donné ton consentement pour l'utilisation de tes données personnelles.", "noConsent": "Tu n'as pas donné ton consentement pour l'utilisation de tes données personnelles.",
"tokenSave": "Impossible de sauvegarder le token de session. Merci de contacter le support.", "tokenSave": "Impossible de sauvegarder le token de session. Merci de contacter le support.",
"tokenRetrieve": "Impossible de récupérer le token de session. Merci de contacter le support.",
"badInput": "Entrée invalide. Merci de réessayer.", "badInput": "Entrée invalide. Merci de réessayer.",
"forbidden": "Tu n'as pas accès à cette information.", "forbidden": "Tu n'as pas accès à cette information.",
"connectionError": "Erreur de réseau. Merci de vérifier ta connexion Internet.", "connectionError": "Erreur de réseau. Merci de vérifier ta connexion Internet.",

View file

@ -51,7 +51,6 @@ function CollapsibleComponent(props: Props) {
const { paddedProps, headerColors } = props; const { paddedProps, headerColors } = props;
const Comp = props.component; const Comp = props.component;
const theme = useTheme(); const theme = useTheme();
console.log(theme.dark);
const { setCollapsible } = useCollapsible(); const { setCollapsible } = useCollapsible();

View file

@ -41,7 +41,7 @@ export type RequestProps = {
type Props<T> = RequestScreenProps<T>; type Props<T> = RequestScreenProps<T>;
const MIN_REFRESH_TIME = 5 * 1000; const MIN_REFRESH_TIME = 3 * 1000;
export default function RequestScreen<T>(props: Props<T>) { export default function RequestScreen<T>(props: Props<T>) {
const navigation = useNavigation<StackNavigationProp<any>>(); const navigation = useNavigation<StackNavigationProp<any>>();
@ -94,8 +94,7 @@ export default function RequestScreen<T>(props: Props<T>) {
clearInterval(refreshInterval.current); clearInterval(refreshInterval.current);
} }
}; };
// eslint-disable-next-line react-hooks/exhaustive-deps }, [props.cache, props.refreshOnFocus, props.autoRefreshTime, refreshData])
}, [props.cache, props.refreshOnFocus])
); );
const isErrorCritical = (e: API_REQUEST_CODES | undefined) => { const isErrorCritical = (e: API_REQUEST_CODES | undefined) => {

View file

@ -44,12 +44,7 @@ type Props<ItemT, RawData> = Omit<
> & > &
Omit< Omit<
RequestScreenProps<RawData>, RequestScreenProps<RawData>,
| 'render' 'render' | 'showLoading' | 'showError' | 'onMajorError'
| 'showLoading'
| 'showError'
| 'refresh'
| 'onFinish'
| 'onMajorError'
> & > &
Omit< Omit<
SectionListProps<ItemT>, SectionListProps<ItemT>,
@ -171,6 +166,8 @@ function WebSectionList<ItemT, RawData>(props: Props<ItemT, RawData>) {
refreshOnFocus={props.refreshOnFocus} refreshOnFocus={props.refreshOnFocus}
cache={props.cache} cache={props.cache}
onCacheUpdate={props.onCacheUpdate} onCacheUpdate={props.onCacheUpdate}
refresh={props.refresh}
onFinish={props.onFinish}
/> />
); );
} }

View file

@ -59,6 +59,7 @@ import {
ProxiwashPreferenceKeys, ProxiwashPreferenceKeys,
} from '../../utils/asyncStorage'; } from '../../utils/asyncStorage';
import { useProxiwashPreferences } from '../../context/preferencesContext'; import { useProxiwashPreferences } from '../../context/preferencesContext';
import { useSubsequentEffect } from '../../utils/customHooks';
const REFRESH_TIME = 1000 * 10; // Refresh every 10 seconds const REFRESH_TIME = 1000 * 10; // Refresh every 10 seconds
const LIST_ITEM_HEIGHT = 64; const LIST_ITEM_HEIGHT = 64;
@ -106,6 +107,7 @@ function ProxiwashScreen() {
ProxiwashPreferenceKeys.proxiwashNotifications, ProxiwashPreferenceKeys.proxiwashNotifications,
preferences preferences
); );
const [refresh, setRefresh] = useState(false);
const getMachinesWatched = () => { const getMachinesWatched = () => {
const data = getPreferenceObject( const data = getPreferenceObject(
@ -130,6 +132,11 @@ function ProxiwashScreen() {
const machinesWatched: Array<ProxiwashMachineType> = getMachinesWatched(); const machinesWatched: Array<ProxiwashMachineType> = getMachinesWatched();
const selectedWash: 'washinsa' | 'tripodeB' = getSelectedWash(); const selectedWash: 'washinsa' | 'tripodeB' = getSelectedWash();
useSubsequentEffect(() => {
// Refresh the list when the selected wash changes
setRefresh(true);
}, [selectedWash]);
const modalStateStrings: { [key in MachineStates]: string } = { const modalStateStrings: { [key in MachineStates]: string } = {
[MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.modal.ready'), [MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.modal.ready'),
[MachineStates.RUNNING]: i18n.t('screens.proxiwash.modal.running'), [MachineStates.RUNNING]: i18n.t('screens.proxiwash.modal.running'),
@ -446,6 +453,7 @@ function ProxiwashScreen() {
default: default:
data = ProxiwashConstants.washinsa; data = ProxiwashConstants.washinsa;
} }
return ( return (
<View style={GENERAL_STYLES.flex}> <View style={GENERAL_STYLES.flex}>
<View style={styles.container}> <View style={styles.container}>
@ -458,6 +466,8 @@ function ProxiwashScreen() {
refreshOnFocus={true} refreshOnFocus={true}
extraData={machinesWatched.length} extraData={machinesWatched.length}
renderListHeaderComponent={renderListHeaderComponent} renderListHeaderComponent={renderListHeaderComponent}
refresh={refresh}
onFinish={() => setRefresh(false)}
/> />
</View> </View>
<MascotPopup <MascotPopup

View file

@ -53,6 +53,10 @@ export function getErrorMessage(
fullMessage.message = i18n.t('errors.tokenSave'); fullMessage.message = i18n.t('errors.tokenSave');
fullMessage.icon = 'alert-circle-outline'; fullMessage.icon = 'alert-circle-outline';
break; break;
case REQUEST_STATUS.TOKEN_RETRIEVE:
fullMessage.message = i18n.t('errors.tokenRetrieve');
fullMessage.icon = 'alert-circle-outline';
break;
default: default:
fullMessage.message = i18n.t('errors.unknown'); fullMessage.message = i18n.t('errors.unknown');
fullMessage.icon = 'alert-circle-outline'; fullMessage.icon = 'alert-circle-outline';