1
0
mirror of https://github.com/tooot-app/app synced 2025-01-04 13:39:42 +01:00

Fix push server key data staled

This commit is contained in:
xmflsct 2022-12-10 13:38:26 +01:00
parent 88312e4df5
commit b449d50b78

View File

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