Skip to content

Commit

Permalink
🤦‍♂️attempt: to fixed the stupid warning
Browse files Browse the repository at this point in the history
  • Loading branch information
thienguen committed Apr 11, 2024
1 parent 06b5a18 commit 5a6ad2f
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 32 deletions.
6 changes: 3 additions & 3 deletions apps/expo/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ const defineConfig = (): ExpoConfig => ({
},
extra: {
// this is commented out so you don't have to log in to run expo start locally
// eas: {
// projectId: 'a5b98934-bf53-4573-ba91-972c22a6759a',
// },
eas: {
projectId: 'a5b98934-bf53-4573-ba91-972c22a6759a',
},
clerkPublishableKey: process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY,
expoPublicClerkPublishableKey: process.env.EXPO_PUBLIC_CLERK_PUBLISHABLE_KEY,
},
Expand Down
1 change: 1 addition & 0 deletions apps/expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.73.6",
"react-native-branch": "^6.2.1",
"react-native-dotenv": "^3.4.10",
"react-native-gesture-handler": "~2.14.1",
"react-native-get-random-values": "^1.8.0",
Expand Down
78 changes: 64 additions & 14 deletions apps/expo/src/app/[...unmatched].tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,66 @@
import { Text } from 'react-native'
import { SafeAreaView } from 'react-native-safe-area-context'
// import { Text } from 'react-native'
// import { SafeAreaView } from 'react-native-safe-area-context'

export default function Page() {
return (
<>
{/* <Redirect href={'/'} /> */}
{alert('This page does not exist')}
<SafeAreaView>
<Text style={ { textAlign: 'center', padding: 30 }}>
This page does not exist
</Text>
</SafeAreaView>
</>
)
// export default function Page() {
// return (
// <>
// {/* <Redirect href={'/'} /> */}
// {alert('This page does not exist')}
// <SafeAreaView>
// <Text style={{ textAlign: 'center', padding: 30 }}>This page does not exist</Text>
// </SafeAreaView>
// </>
// )
// }

import React, { useEffect, useState } from 'react'
import branch from 'react-native-branch'
import { Unmatched, useFocusEffect, useRouter } from 'expo-router'

export default function CustomUnmatched() {
const [branchLoading, setBranchLoading] = useState(true)
const [goNext, setGoNext] = useState('')
const router = useRouter()

useFocusEffect(() => {
branch.subscribe({
onOpenStart: ({ uri, cachedInitialEvent }) => {
if (uri == null) {
setBranchLoading(false)
return
}
},
onOpenComplete: ({ error, params, uri }) => {
if (error) {
console.error(
'subscribe onOpenComplete, Error from opening uri: ' + uri + ' error: ' + error,
)
return
}
if (!params?.['+clicked_branch_link']) {
setBranchLoading(false)
return
} else {
let canonicalIdentifier = params.$canonical_identifier as string
if (canonicalIdentifier) {
setGoNext(canonicalIdentifier)
}
// Route based on Branch link data
setBranchLoading(false)
return
}
},
})

return () => {
// branch.unsubscribe();
}
})
useEffect(() => {
if (goNext !== undefined) {
router.push(goNext as any)
}
}, [goNext])

return branchLoading ? null : <Unmatched />
}
2 changes: 1 addition & 1 deletion apps/expo/src/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default function RootLayout() {

return (
<ClerkProvider publishableKey={CLERK_PUBLISHABLE_KEY!} tokenCache={tokenCache}>
{isDevelopment ? (
{!isDevelopment ? (
<AppContent />
) : (
<>
Expand Down
7 changes: 7 additions & 0 deletions apps/expo/src/app/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { router } from 'expo-router'

const Default = () => {
router.push('(dashboard)/')
}

export default Default
32 changes: 19 additions & 13 deletions apps/expo/src/components/auth/sign-in-w-google.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,25 @@ const SignInWithGoogle = () => {

const SignInWithGoogleOAuth = React.useCallback(async () => {
try {
const { createdSessionId, setActive } = await startGoogleOAuthFlow()
// console.log('startOAuthFlow')

if (createdSessionId && setActive) {
await setActive({ session: createdSessionId })

// FIXME: WARN The navigation state parsed from the URL contains routes not present in the root navigator.
// This usually means that the linking configuration doesn't match the navigation structure.
// See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.
// router.push('(dashboard)/')
} else {
// FIXME: Change this to a toast or style this alert
alert('Sign in failed')
if (isEnabled) {
setIsEnabled(false)
const { createdSessionId, setActive } = await startGoogleOAuthFlow()

// console.log('startOAuthFlow')

if (createdSessionId && setActive) {
await setActive({ session: createdSessionId })

// FIXME: WARN The navigation state parsed from the URL contains routes not present in the root navigator.
// This usually means that the linking configuration doesn't match the navigation structure.
// See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.
// router.push('(dashboard)/')
} else {
// FIXME: Change this to a toast or style this alert
alert('Sign in failed')
}

setIsEnabled(true)
}
} catch (err: any) {
Alert.alert(
Expand Down
5 changes: 4 additions & 1 deletion apps/expo/src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export default function getErrorMessage(error: unknown) {
else return String(error)
}


export function makeChatName(users: any[], userData: any): string {
const filteredUsers = users.filter((user) => userData.username.trim() !== user.username.trim())

Expand All @@ -21,3 +20,7 @@ export function makeChatName(users: any[], userData: any): string {
}
return String(filteredUsers[0].username?.trim() + ' and ' + filteredUsers[1].username.trim())
}

export function log(msg = '') {
return console.log(new Date() + ':> ' + msg)
}
11 changes: 11 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5a6ad2f

Please sign in to comment.