diff --git a/src/screens/Tabs/Me/Push.tsx b/src/screens/Tabs/Me/Push.tsx index fd37f3ca..8c549f2e 100644 --- a/src/screens/Tabs/Me/Push.tsx +++ b/src/screens/Tabs/Me/Push.tsx @@ -35,12 +35,7 @@ const TabMePush: React.FC = () => { const instance = useSelector(getInstance) const expoToken = useSelector(getExpoToken) - const [serverKeyAvailable, setServerKeyAvailable] = useState() - 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 ( - {!!serverKeyAvailable ? ( + {!!appsQuery.data?.vapid_key ? ( <> {!!pushAvailable ? ( <>