Fix push server key data staled

This commit is contained in:
xmflsct 2022-12-10 13:38:26 +01:00
parent 88312e4df5
commit b449d50b78
1 changed files with 4 additions and 9 deletions

View File

@ -35,12 +35,7 @@ const TabMePush: React.FC = () => {
const instance = useSelector(getInstance)
const expoToken = useSelector(getExpoToken)
const [serverKeyAvailable, setServerKeyAvailable] = useState<boolean>()
useAppsQuery({
options: {
onSuccess: data => setServerKeyAvailable(!!data.vapid_key)
}
})
const appsQuery = useAppsQuery()
const dispatch = useAppDispatch()
const instancePush = useSelector(getInstancePush)
@ -66,7 +61,7 @@ const TabMePush: React.FC = () => {
}
}
if (serverKeyAvailable) {
if (appsQuery.data?.vapid_key) {
checkPush()
if (isDevelopment) {
@ -80,7 +75,7 @@ const TabMePush: React.FC = () => {
return () => {
subscription.remove()
}
}, [serverKeyAvailable])
}, [appsQuery.data?.vapid_key])
const alerts = () =>
instancePush?.alerts
@ -133,7 +128,7 @@ const TabMePush: React.FC = () => {
return (
<ScrollView>
{!!serverKeyAvailable ? (
{!!appsQuery.data?.vapid_key ? (
<>
{!!pushAvailable ? (
<>