-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ml/fix deeplink to groupchat #1395
Changes from 10 commits
24975c4
8f6ba7c
cfa6299
0a0fa5b
956242a
b02e0fb
c9c012b
e6dc449
2ebf4f0
807aff5
6d4539e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,11 +24,11 @@ import { JoinGroupResult } from "./joinGroup.types"; | |
import { ConversationListQueryData } from "@/queries/useConversationListQuery"; | ||
import { entify } from "@/queries/entify"; | ||
import { GroupWithCodecsType } from "@/utils/xmtpRN/client"; | ||
import { wait } from "@/utils/wait"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change is because I realized we had a utility for this already |
||
|
||
const GROUP_JOIN_REQUEST_POLL_MAX_ATTEMPTS = 10; | ||
const GROUP_JOIN_REQUEST_POLL_INTERVAL_MS = 1000; | ||
|
||
const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms)); | ||
/** | ||
* TODOs: | ||
* | ||
|
@@ -187,7 +187,7 @@ export class JoinGroupClient { | |
logger.debug( | ||
`[liveAttemptToJoinGroup] Waiting ${GROUP_JOIN_REQUEST_POLL_INTERVAL_MS}ms before next poll` | ||
); | ||
await sleep(GROUP_JOIN_REQUEST_POLL_INTERVAL_MS); | ||
await wait(GROUP_JOIN_REQUEST_POLL_INTERVAL_MS); | ||
} | ||
|
||
logger.warn( | ||
|
@@ -522,7 +522,7 @@ export class JoinGroupClient { | |
account: string, | ||
groupInviteId: string | ||
): Promise<JoinGroupResult> => { | ||
await sleep(5000); | ||
await wait(5000); | ||
return { | ||
type: "group-join-request.timed-out", | ||
} as const; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
import * as Notifications from "expo-notifications"; | ||
import { | ||
navigate, | ||
navigateToTopic, | ||
setTopicToNavigateTo, | ||
} from "@utils/navigation"; | ||
import { navigate, navigateToTopic } from "@utils/navigation"; | ||
import { getTopicFromV3Id } from "@utils/groupUtils/groupId"; | ||
import { useAccountsStore } from "@data/store/accountsStore"; | ||
import type { ConversationId, ConversationTopic } from "@xmtp/react-native-sdk"; | ||
import { fetchPersistedConversationListQuery } from "@/queries/useConversationListQuery"; | ||
import { resetNotifications } from "./resetNotifications"; | ||
import logger from "@/utils/logger"; | ||
import { getXmtpClient } from "@/utils/xmtpRN/sync"; | ||
import { ConverseXmtpClientType } from "@/utils/xmtpRN/client"; | ||
import { waitForXmtpClientHydration } from "@/data/store/appStore"; | ||
import logger from "@utils/logger"; | ||
|
||
export const onInteractWithNotification = async ( | ||
event: Notifications.NotificationResponse | ||
) => { | ||
logger.debug("[onInteractWithNotification]"); | ||
// todo(lustig): zod verification of external payloads such as those from | ||
// notifications, deep links, etc | ||
let notificationData = event.notification.request.content.data; | ||
// Android returns the data in the body as a string | ||
if ( | ||
|
@@ -58,40 +55,13 @@ export const onInteractWithNotification = async ( | |
| undefined; | ||
|
||
if (conversationTopic) { | ||
// todo(lustig): zod verification of external payloads such as those from | ||
// notifications, deep links, etc | ||
await waitForXmtpClientHydration(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out all the crap I was doing before in the previous diff uh was done in client hydration so it's not needed here |
||
const account: string = | ||
notificationData["account"] || useAccountsStore.getState().currentAccount; | ||
|
||
// Fetch the conversation list to ensure we have the latest conversation list | ||
// before navigating to the conversation | ||
try { | ||
await fetchPersistedConversationListQuery({ account }); | ||
} catch (e) { | ||
logger.error( | ||
`[onInteractWithNotification] Error fetching conversation list from network` | ||
); | ||
if ( | ||
`${e}`.includes("storage error: Pool needs to reconnect before use") | ||
) { | ||
logger.info( | ||
`[onInteractWithNotification] Reconnecting XMTP client for account ${account}` | ||
); | ||
const client = (await getXmtpClient(account)) as ConverseXmtpClientType; | ||
await client.reconnectLocalDatabase(); | ||
logger.info( | ||
`[onInteractWithNotification] XMTP client reconnected for account ${account}` | ||
); | ||
logger.info( | ||
`[onInteractWithNotification] Fetching conversation list from network for account ${account}` | ||
); | ||
await fetchPersistedConversationListQuery({ account }); | ||
} | ||
} | ||
useAccountsStore.getState().setCurrentAccount(account, false); | ||
|
||
navigateToTopic(conversationTopic as ConversationTopic); | ||
setTopicToNavigateTo(undefined); | ||
resetNotifications(); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ import { useThemeProvider } from "../theme/useAppTheme"; | |
import { useAddressBookStateHandler } from "../utils/addressBook"; | ||
import { useAutoConnectExternalWallet } from "../utils/evm/external"; | ||
import { usePrivyAccessToken } from "../utils/evm/privy"; | ||
import { converseNavigations } from "../utils/navigation"; | ||
import { setConverseNavigatorRef } from "../utils/navigation"; | ||
import { ConversationScreenConfig } from "../features/conversation/conversation.nav"; | ||
import { GroupScreenConfig } from "./Navigation/GroupNav"; | ||
import { | ||
|
@@ -39,6 +39,7 @@ import { | |
getConverseStateFromPath, | ||
} from "./Navigation/navHelpers"; | ||
import { JoinGroupScreenConfig } from "@/features/GroupInvites/joinGroup/JoinGroupNavigation"; | ||
import logger from "@/utils/logger"; | ||
|
||
const prefix = Linking.createURL("/"); | ||
|
||
|
@@ -84,9 +85,10 @@ export default function Main() { | |
theme={navigationTheme} | ||
linking={linking} | ||
ref={(r) => { | ||
if (r) { | ||
converseNavigations["main"] = r; | ||
} | ||
logger.info( | ||
`[Main] Setting navigation ref to ${r ? "not null" : "null"}` | ||
); | ||
setConverseNavigatorRef(r); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We only have one navigation ref now that we are no longer supporting different layouts and stuff so I did some refactoring to reflect that |
||
}} | ||
onUnhandledAction={() => { | ||
// Since we're handling multiple navigators, | ||
|
@@ -105,9 +107,7 @@ export default function Main() { | |
const NavigationContent = () => { | ||
const authStatus = useAuthStatus(); | ||
|
||
const { splashScreenHidden } = useAppStore( | ||
useSelect(["notificationsPermissionStatus", "splashScreenHidden"]) | ||
); | ||
const { splashScreenHidden } = useAppStore(useSelect(["splashScreenHidden"])); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unused |
||
|
||
// Uncomment to test design system components | ||
// return ( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explained here: https://www.loom.com/share/d1967df857fb4d1984cbdce195ff7739