Refresh settings for plan on focus

Closes #118
This commit is contained in:
Brandon Presley 2022-11-16 17:05:49 +13:00
parent 261f1c8bf0
commit 1d8d7b070e
1 changed files with 7 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import {RouteProp, useRoute} from '@react-navigation/native'
import {RouteProp, useFocusEffect, useRoute} from '@react-navigation/native'
import {useCallback, useEffect, useMemo, useRef, useState} from 'react'
import {NativeModules, TextInput, View} from 'react-native'
import {FlatList} from 'react-native-gesture-handler'
@ -76,9 +76,14 @@ export default function StartPlan() {
[counts, best],
)
useFocusEffect(
useCallback(() => {
settingsRepo.findOne({where: {}}).then(setSettings)
}, []),
)
useEffect(() => {
refresh().then(newCounts => select(0, newCounts))
settingsRepo.findOne({where: {}}).then(setSettings)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [refresh])