Skip to content

Commit

Permalink
fix: linking from stateful notifications (#3255)
Browse files Browse the repository at this point in the history
  • Loading branch information
UncleSamtoshi authored May 9, 2024
1 parent b121f48 commit 9b6ca50
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions app/screens/notification-history-screen/notification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import {
useStatefulNotificationAcknowledgeMutation,
} from "@app/graphql/generated"
import { Text, makeStyles } from "@rneui/themed"
import { View } from "react-native"
import { View, Linking } from "react-native"
import { timeAgo } from "./utils"
import { gql } from "@apollo/client"
import { TouchableWithoutFeedback } from "react-native-gesture-handler"
import { useLinkTo } from "@react-navigation/native"
import { useState } from "react"

const BLINK_DEEP_LINK_PREFIX = "blink:/"

gql`
mutation StatefulNotificationAcknowledge(
$input: StatefulNotificationAcknowledgeInput!
Expand Down Expand Up @@ -38,15 +39,13 @@ export const Notification: React.FC<StatefulNotification> = ({
variables: { input: { notificationId: id } },
refetchQueries: [StatefulNotificationsDocument],
})

const linkTo = useLinkTo()

const prefixedDeepLink = deepLink ? `${BLINK_DEEP_LINK_PREFIX}${deepLink}` : undefined
return (
<TouchableWithoutFeedback
onPress={() => {
setIsAcknowledged(true)
!isAcknowledged && ack()
deepLink && linkTo(deepLink)
prefixedDeepLink && Linking.openURL(prefixedDeepLink)
}}
>
<View style={styles.container}>
Expand Down

0 comments on commit 9b6ca50

Please sign in to comment.