Skip to content

Commit

Permalink
[fix] resolve merge conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
ronniebeggs committed Jun 4, 2024
2 parents a5f5288 + 208feb8 commit bf7af67
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 97 deletions.
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"NSMicrophoneUsageDescription": "Allow $(PRODUCT_NAME) to access your microphone"
},
"bundleIdentifier": "org.calblueprint.impactfund",
"buildNumber": "15"
"buildNumber": "16"
},
"android": {
"adaptiveIcon": {
Expand All @@ -48,7 +48,7 @@
[
"expo-notifications",
{
"icon": "./assets/icon.png",
"icon": "./assets/notification-logo.png",
"color": "#ffffff"
}
]
Expand Down
Binary file added assets/notification-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 0 additions & 40 deletions eas.json

This file was deleted.

112 changes: 57 additions & 55 deletions src/app/(BottomTabNavigation)/AllCases/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Linking from 'expo-linking';
// import * as Linking from 'expo-linking';
import * as Notifications from 'expo-notifications';
import { router } from 'expo-router';
import React, { useContext, useState, useEffect, useRef } from 'react';
Expand All @@ -16,69 +16,70 @@ import {
} from '../../../supabase/pushNotifications';

import 'react-native-url-polyfill/auto';
enum linkingEvents {
ADD_CASE = 'addCase',
NOTIFICATION = 'notification',
}

function CasesScreen() {
Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: false,
shouldSetBadge: false,
}),
});
// enum linkingEvents {
// ADD_CASE = 'addCase',
// NOTIFICATION = 'notification',
// }

Notifications.setNotificationHandler({
handleNotification: async () => ({
shouldShowAlert: true,
shouldPlaySound: false,
shouldSetBadge: false,
}),
});

function CasesScreen() {
const notificationListener = useRef<Notifications.Subscription>();
const responseListener = useRef<Notifications.Subscription>();

const { allCases, loading } = useContext(CaseContext);
const { session } = useSession();
const [notificationResponse, setNotificationResponse] = useState<string>('');

const [url, setUrl] = useState<Linking.ParsedURL | null>(null);

function urlRedirect(parsedUrl: Linking.ParsedURL) {
if (!parsedUrl) return;
// parse query params and determine routing
const { queryParams } = parsedUrl;
// determine routing from the event variable
if (queryParams?.event) {
const event = queryParams.event.toString();
// TODO: determine a way to validate required parameters
// TODO: prevent users from routing to a case they're already involved in
if (event === linkingEvents.ADD_CASE)
router.push({
pathname: `/AllCases/AddCase/${queryParams.caseUid}`,
});
}
}

function handleDeepLink(event: any) {
const parsedUrl = Linking.parse(event.url);
if (parsedUrl) {
setUrl(parsedUrl);
urlRedirect(parsedUrl);
}
}

async function getInitialUrl() {
const initialUrl = await Linking.getInitialURL();
if (initialUrl) {
const parsed = Linking.parse(initialUrl);
setUrl(parsed);
urlRedirect(parsed);
}
}
// const [url, setUrl] = useState<Linking.ParsedURL | null>(null);

// function urlRedirect(parsedUrl: Linking.ParsedURL) {
// if (!parsedUrl) return;
// // parse query params and determine routing
// const { queryParams } = parsedUrl;
// // determine routing from the event variable
// if (queryParams?.event) {
// const event = queryParams.event.toString();
// // TODO: determine a way to validate required parameters
// // TODO: prevent users from routing to a case they're already involved in
// if (event === linkingEvents.ADD_CASE)
// router.push({
// pathname: `/AllCases/AddCase/${queryParams.caseUid}`,
// });
// }
// }

// function handleDeepLink(event: any) {
// const parsedUrl = Linking.parse(event.url);
// if (parsedUrl) {
// setUrl(parsedUrl);
// urlRedirect(parsedUrl);
// }
// }

// async function getInitialUrl() {
// const initialUrl = await Linking.getInitialURL();
// if (initialUrl) {
// const parsed = Linking.parse(initialUrl);
// setUrl(parsed);
// urlRedirect(parsed);
// }
// }

useEffect(() => {
// will detect any incoming link requests, assuming the app is already open
Linking.addEventListener('url', handleDeepLink);
if (!url) {
// if the link opened the app, must route to the initial incoming route
getInitialUrl();
}
// // will detect any incoming link requests, assuming the app is already open
// Linking.addEventListener('url', handleDeepLink);
// if (!url) {
// // if the link opened the app, must route to the initial incoming route
// getInitialUrl();
// }

if (session?.user) {
registerForPushNotifications().then(async (token: string) => {
Expand All @@ -88,7 +89,7 @@ function CasesScreen() {

notificationListener.current =
Notifications.addNotificationReceivedListener(notification => {
const updateId = notification.request.content.data['id'];
const updateId = notification.request.content.data.updateId;
const debugString =
'NotificationRecieved: ' +
notification +
Expand All @@ -105,7 +106,7 @@ function CasesScreen() {

responseListener.current =
Notifications.addNotificationResponseReceivedListener(response => {
const updateId = response.notification.request.content.data['id'];
const updateId = response.notification.request.content.data.updateId;
const debugString =
'NotificationResponseRecieved: ' +
response +
Expand Down Expand Up @@ -142,6 +143,7 @@ function CasesScreen() {
ListHeaderComponent={() => (
<>
<View style={styles.headerContainer}>
<Text>Notifications Debug: {notificationResponse}</Text>
<Text style={fonts.tabHeading}>My Cases</Text>
</View>
</>
Expand Down

0 comments on commit bf7af67

Please sign in to comment.