Handle notifee card presses
This commit is contained in:
+4
-3
@@ -1,9 +1,10 @@
|
||||
import notifee, {EventType} from '@notifee/react-native'
|
||||
import {StackActions} from '@react-navigation/native'
|
||||
import {AppBskyEmbedImages} from '@atproto/api'
|
||||
import {RootStoreModel} from 'state/models/root-store'
|
||||
import {TabPurpose} from 'state/models/navigation'
|
||||
import {NotificationsViewItemModel} from 'state/models/notifications-view'
|
||||
import {enforceLen} from 'lib/strings/helpers'
|
||||
import {navigation} from '../Routes'
|
||||
|
||||
export function init(store: RootStoreModel) {
|
||||
store.onUnreadNotifications(count => notifee.setBadgeCount(count))
|
||||
@@ -16,8 +17,8 @@ export function init(store: RootStoreModel) {
|
||||
store.log.debug('Notifee foreground event', {type})
|
||||
if (type === EventType.PRESS) {
|
||||
store.log.debug('User pressed a notifee, opening notifications')
|
||||
// TODO
|
||||
// store.nav.switchTo(TabPurpose.Notifs, true)
|
||||
navigation.navigate('NotificationsTab')
|
||||
navigation.dispatch(StackActions.popToTop())
|
||||
}
|
||||
})
|
||||
notifee.onBackgroundEvent(async _e => {}) // notifee requires this but we handle it with onForegroundEvent
|
||||
|
||||
@@ -40,6 +40,15 @@ export type NotificationsDrawerNavigatorParams = {
|
||||
NotificationsInner: undefined
|
||||
}
|
||||
|
||||
export type AllNavigatorParams = CommonNavigatorParams & {
|
||||
HomeTab: undefined
|
||||
Home: undefined
|
||||
SeachTab: undefined
|
||||
Search: undefined
|
||||
NotificationsTab: undefined
|
||||
Notifications: undefined
|
||||
}
|
||||
|
||||
// NOTE
|
||||
// this isn't strictly correct but it should be close enough
|
||||
// a TS wizard might be able to get this 100%
|
||||
|
||||
+18
-6
@@ -1,5 +1,8 @@
|
||||
import * as React from 'react'
|
||||
import {NavigationContainer} from '@react-navigation/native'
|
||||
import {
|
||||
NavigationContainer,
|
||||
createNavigationContainerRef,
|
||||
} from '@react-navigation/native'
|
||||
import {createNativeStackNavigator} from '@react-navigation/native-stack'
|
||||
import {createDrawerNavigator} from '@react-navigation/drawer'
|
||||
import {createBottomTabNavigator} from '@react-navigation/bottom-tabs'
|
||||
@@ -11,6 +14,7 @@ import {
|
||||
SearchDrawerNavigatorParams,
|
||||
NotificationsTabNavigatorParams,
|
||||
NotificationsDrawerNavigatorParams,
|
||||
AllNavigatorParams,
|
||||
State,
|
||||
} from 'lib/routes/types'
|
||||
|
||||
@@ -31,6 +35,8 @@ import {PostRepostedByScreen} from './view/screens/PostRepostedBy'
|
||||
import {DebugScreen} from './view/screens/Debug'
|
||||
import {LogScreen} from './view/screens/Log'
|
||||
|
||||
const navigationRef = createNavigationContainerRef<AllNavigatorParams>()
|
||||
|
||||
const HomeDrawer = createDrawerNavigator<HomeDrawerNavigatorParams>()
|
||||
const HomeTab = createNativeStackNavigator<HomeTabNavigatorParams>()
|
||||
const SearchDrawer = createDrawerNavigator<SearchDrawerNavigatorParams>()
|
||||
@@ -87,7 +93,7 @@ const ROUTES: Record<string, Route> = {
|
||||
Log: r('/sys/log'),
|
||||
}
|
||||
|
||||
export function matchPath(path: string): {name: string; params: RouteParams} {
|
||||
function matchPath(path: string): {name: string; params: RouteParams} {
|
||||
let name = 'NotFound'
|
||||
let params: RouteParams = {}
|
||||
for (const [screenName, matcher] of Object.entries(ROUTES)) {
|
||||
@@ -101,7 +107,7 @@ export function matchPath(path: string): {name: string; params: RouteParams} {
|
||||
return {name, params}
|
||||
}
|
||||
|
||||
export const LINKING = {
|
||||
const LINKING = {
|
||||
prefixes: ['bsky://', 'https://bsky.app'],
|
||||
|
||||
getPathFromState(state: State) {
|
||||
@@ -245,7 +251,7 @@ function NotificationsTabNavigator() {
|
||||
)
|
||||
}
|
||||
|
||||
export function TabsNavigator() {
|
||||
function TabsNavigator() {
|
||||
const tabBar = React.useCallback(props => <BottomBar {...props} />, [])
|
||||
return (
|
||||
<Tab.Navigator
|
||||
@@ -263,6 +269,12 @@ export function TabsNavigator() {
|
||||
)
|
||||
}
|
||||
|
||||
export function RoutesContainer({children}: React.PropsWithChildren<{}>) {
|
||||
return <NavigationContainer linking={LINKING}>{children}</NavigationContainer>
|
||||
function RoutesContainer({children}: React.PropsWithChildren<{}>) {
|
||||
return (
|
||||
<NavigationContainer ref={navigationRef} linking={LINKING}>
|
||||
{children}
|
||||
</NavigationContainer>
|
||||
)
|
||||
}
|
||||
|
||||
export {navigationRef as navigation, matchPath, TabsNavigator, RoutesContainer}
|
||||
|
||||
Reference in New Issue
Block a user