diff --git a/src/components/Screens/RequestScreen.tsx b/src/components/Screens/RequestScreen.tsx index 5c0055d..6d6550d 100644 --- a/src/components/Screens/RequestScreen.tsx +++ b/src/components/Screens/RequestScreen.tsx @@ -41,7 +41,7 @@ export type RequestProps = { type Props = RequestScreenProps; -const MIN_REFRESH_TIME = 5 * 1000; +const MIN_REFRESH_TIME = 3 * 1000; export default function RequestScreen(props: Props) { const navigation = useNavigation>(); @@ -94,8 +94,7 @@ export default function RequestScreen(props: Props) { clearInterval(refreshInterval.current); } }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [props.cache, props.refreshOnFocus]) + }, [props.cache, props.refreshOnFocus, props.autoRefreshTime, refreshData]) ); const isErrorCritical = (e: API_REQUEST_CODES | undefined) => { diff --git a/src/components/Screens/WebSectionList.tsx b/src/components/Screens/WebSectionList.tsx index d790fa7..f6df60f 100644 --- a/src/components/Screens/WebSectionList.tsx +++ b/src/components/Screens/WebSectionList.tsx @@ -44,12 +44,7 @@ type Props = Omit< > & Omit< RequestScreenProps, - | 'render' - | 'showLoading' - | 'showError' - | 'refresh' - | 'onFinish' - | 'onMajorError' + 'render' | 'showLoading' | 'showError' | 'onMajorError' > & Omit< SectionListProps, @@ -171,6 +166,8 @@ function WebSectionList(props: Props) { refreshOnFocus={props.refreshOnFocus} cache={props.cache} onCacheUpdate={props.onCacheUpdate} + refresh={props.refresh} + onFinish={props.onFinish} /> ); } diff --git a/src/screens/Proxiwash/ProxiwashScreen.tsx b/src/screens/Proxiwash/ProxiwashScreen.tsx index b4ab57f..ea60431 100644 --- a/src/screens/Proxiwash/ProxiwashScreen.tsx +++ b/src/screens/Proxiwash/ProxiwashScreen.tsx @@ -59,6 +59,7 @@ import { ProxiwashPreferenceKeys, } from '../../utils/asyncStorage'; import { useProxiwashPreferences } from '../../context/preferencesContext'; +import { useSubsequentEffect } from '../../utils/customHooks'; const REFRESH_TIME = 1000 * 10; // Refresh every 10 seconds const LIST_ITEM_HEIGHT = 64; @@ -106,6 +107,7 @@ function ProxiwashScreen() { ProxiwashPreferenceKeys.proxiwashNotifications, preferences ); + const [refresh, setRefresh] = useState(false); const getMachinesWatched = () => { const data = getPreferenceObject( @@ -130,6 +132,11 @@ function ProxiwashScreen() { const machinesWatched: Array = getMachinesWatched(); const selectedWash: 'washinsa' | 'tripodeB' = getSelectedWash(); + useSubsequentEffect(() => { + // Refresh the list when the selected wash changes + setRefresh(true); + }, [selectedWash]); + const modalStateStrings: { [key in MachineStates]: string } = { [MachineStates.AVAILABLE]: i18n.t('screens.proxiwash.modal.ready'), [MachineStates.RUNNING]: i18n.t('screens.proxiwash.modal.running'), @@ -446,6 +453,7 @@ function ProxiwashScreen() { default: data = ProxiwashConstants.washinsa; } + return ( @@ -458,6 +466,8 @@ function ProxiwashScreen() { refreshOnFocus={true} extraData={machinesWatched.length} renderListHeaderComponent={renderListHeaderComponent} + refresh={refresh} + onFinish={() => setRefresh(false)} />