diff options
author | Hailey <me@haileyok.com> | 2024-05-13 09:19:35 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-13 09:19:35 -0700 |
commit | d3406c89cf0c5b46197a87298dcd4e1326fef643 (patch) | |
tree | 6495ae6ca57f07077500a2e69f6cdc1c334be33e /src/view/screens/Home.tsx | |
parent | 63b38b413d7a9e243646d11219b0959b3e59cc79 (diff) | |
download | voidsky-d3406c89cf0c5b46197a87298dcd4e1326fef643.tar.zst |
Move request for notifications permissions to `HomeReadyScreen` (#3977)
* cleanup the current logic * add statsig logs * implement requests for permissions where needed * oops * let `addPushTokenListener` handle the token registration * place new log event type with the other `notifications` type * place registration next to handler * more organization * only call `gate()` if permission is not yet granted * be more specific to prevent gate pollution * nit * make `token` non-optional in `registerToken` * remove `prevDid`, move `registerPushToken` into `useEffect` * keep it outside actually * nit
Diffstat (limited to 'src/view/screens/Home.tsx')
-rw-r--r-- | src/view/screens/Home.tsx | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/view/screens/Home.tsx b/src/view/screens/Home.tsx index bd17e5fe4..d2d31ce6a 100644 --- a/src/view/screens/Home.tsx +++ b/src/view/screens/Home.tsx @@ -20,6 +20,7 @@ import { } from '#/state/shell' import {useSelectedFeed, useSetSelectedFeed} from '#/state/shell/selected-feed' import {useOTAUpdates} from 'lib/hooks/useOTAUpdates' +import {useRequestNotificationsPermission} from 'lib/notifications/notifications' import {HomeTabNavigatorParams, NativeStackScreenProps} from 'lib/routes/types' import {FeedPage} from 'view/com/feeds/FeedPage' import {Pager, PagerRef, RenderTabBarFnProps} from 'view/com/pager/Pager' @@ -58,7 +59,9 @@ function HomeScreenReady({ preferences: UsePreferencesQueryResponse pinnedFeedInfos: SavedFeedSourceInfo[] }) { - useOTAUpdates() + const gate = useGate() + const requestNotificationsPermission = useRequestNotificationsPermission() + const allFeeds = React.useMemo( () => pinnedFeedInfos.map(f => f.feedDescriptor), [pinnedFeedInfos], @@ -70,6 +73,11 @@ function HomeScreenReady({ const selectedFeed = allFeeds[selectedIndex] useSetTitle(pinnedFeedInfos[selectedIndex]?.displayName) + useOTAUpdates() + + React.useEffect(() => { + requestNotificationsPermission('AfterOnboarding') + }, [requestNotificationsPermission]) const pagerRef = React.useRef<PagerRef>(null) const lastPagerReportedIndexRef = React.useRef(selectedIndex) @@ -109,7 +117,6 @@ function HomeScreenReady({ }), ) - const gate = useGate() const mode = useMinimalShellMode() const {isMobile} = useWebMediaQueries() useFocusEffect( |