Skip to content
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

Merged
merged 11 commits into from
Dec 19, 2024
Merged

Conversation

technoplato
Copy link
Collaborator

@technoplato technoplato commented Dec 19, 2024

https://www.loom.com/share/d1967df857fb4d1984cbdce195ff7739

Summary by CodeRabbit

  • New Features

    • Introduced a utility function to manage app store hydration.
    • Added navigation reference management to enhance navigation handling.
  • Bug Fixes

    • Improved error handling and logging for navigation actions.
  • Refactor

    • Streamlined conversation handling and navigation logic for better performance and clarity.
    • Simplified state management in the navigation component.
    • Replaced custom sleep function with a standardized wait function for delays in group joining processes.
    • Adjusted platform flavor determination logic to include temporary Jest environment checks.
  • Chores

    • Updated import statements for cleaner code.

@technoplato technoplato requested a review from a team as a code owner December 19, 2024 17:16
Copy link
Contributor

coderabbitai bot commented Dec 19, 2024

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request introduces a new utility function waitForXmtpClientHydration to ensure the app store's hydration is complete before navigation occurs. Modifications include a refactor of navigation handling with the introduction of converseNavigatorRef and setConverseNavigatorRef, enhancing error management. The onInteractWithNotification function is updated to call the new hydration utility, streamlining the control flow regarding XMTP client readiness and navigation references. Additionally, the navigation logic has been simplified across various components.

Changes

File Change Summary
data/store/appStore.ts Added waitForXmtpClientHydration() utility function to wait for app store hydration
features/notifications/utils/onInteractWithNotification.ts Removed conversation list fetching logic, added waitForXmtpClientHydration() call
screens/Main.tsx Updated navigation reference handling, simplified useAppStore hook usage
utils/navigation.ts Introduced converseNavigatorRef, added setConverseNavigatorRef(), updated navigate() function
dependencies/Environment/Flavors/determineFlavor.utils.ts Added Jest environment check to determineDependencyFlavor function
features/GroupInvites/joinGroup/JoinGroup.client.ts Replaced sleep function with wait utility for delays in group joining methods

Possibly related PRs

Suggested reviewers

  • alexrisch

Poem

🐰 In the garden of code, we hop and play,
With hydration in hand, we pave the way.
Navigation's a dance, so smooth and bright,
Guiding our users from morning to night.
Errors now vanish, like dew in the sun,
A rabbit's delight, our work here is done! 🌟

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 807aff5 and 6d4539e.

📒 Files selected for processing (3)
  • features/GroupInvites/joinGroup/JoinGroup.client.ts (2 hunks)
  • features/notifications/utils/onInteractWithNotification.ts (2 hunks)
  • utils/navigation.ts (1 hunks)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented Dec 19, 2024

Performance Comparison Report

  • Current: ad345aa - 2024-12-19 21:10:23Z
  • Baseline: release/3.0.0 (b8567b4) - 2024-12-19 21:09:03Z

Significant Changes To Duration

There are no entries

Meaningless Changes To Duration

Show entries
Name Type Duration Count
Avatar Image 10 runs render 1.2 ms → 1.1 ms (-0.1 ms, -8.3%) 1 → 1
Avatar Image 50 runs render 1.1 ms → 1.1 ms (+0.0 ms, +3.6%) 1 → 1
Empty Avatar 10 runs render 0.8 ms → 0.7 ms (-0.1 ms, -12.5%) 1 → 1
Empty Avatar 50 runs render 0.7 ms → 0.7 ms (+0.0 ms, +5.9%) 1 → 1
Text Component with color prop - 10 runs render 0.0 ms → 0.3 ms (+0.3 ms, +Infinity%) 🔴 1 → 1
Text Component with default props - 10 runs render 0.1 ms → 0.2 ms (+0.1 ms, +100.0%) 🔴 1 → 1
Text Component with translation key - 10 runs render 0.2 ms → 0.4 ms (+0.2 ms, +100.0%) 🔴 1 → 1
Text Component with weight and size - 10 runs render 0.2 ms → 0.3 ms (+0.1 ms, +50.0%) 🔴 1 → 1
Show details
Name Type Duration Count
Avatar Image 10 runs render Baseline
Mean: 1.2 ms
Stdev: 0.4 ms (35.1%)
Runs: 1 1 1 1 1 2 1 1 1 2
Warmup runs: 2

Current
Mean: 1.1 ms
Stdev: 0.3 ms (28.7%)
Runs: 1 1 1 1 1 1 1 2 1 1
Warmup runs: 2
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Avatar Image 50 runs render Baseline
Mean: 1.1 ms
Stdev: 0.3 ms (27.5%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 2 1 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1 2 1
Warmup runs: 1

Current
Mean: 1.1 ms
Stdev: 0.4 ms (35.5%)
Runs: 1 1 1 2 2 1 1 1 2 1 2 1 1 1 1 1 1 2 2 1 2 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 2 1 1 1 1 1 1 1
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:
Empty Avatar 10 runs render Baseline
Mean: 0.8 ms
Stdev: 0.4 ms (52.7%)
Runs: 1 1 1 0 1 1 1 1 1 0
Warmup runs: 3

Current
Mean: 0.7 ms
Stdev: 0.5 ms (69.0%)
Runs: 1 0 0 0 1 1 1 1 1 1
Warmup runs: 3
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Empty Avatar 50 runs render Baseline
Mean: 0.7 ms
Stdev: 0.5 ms (69.3%)
Runs: 1 1 0 1 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 0 1 0 0 0 1 0 1 0 1 1 1 0 1 1 0 1 0 0 0 1 1 1 1 1 0 1 1 1 0
Warmup runs: 1

Current
Mean: 0.7 ms
Stdev: 0.5 ms (63.0%)
Runs: 0 1 1 0 0 1 0 1 1 1 1 1 0 1 1 0 1 1 1 1 1 1 1 0 1 0 0 1 1 0 0 1 1 1 1 1 0 0 1 1 1 1 1 1 1 0 1 1 1 1
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with color prop - 10 runs render Baseline
Mean: 0.0 ms
Stdev: 0.0 ms (NaN%)
Runs: 0 0 0 0 0 0 0 0 0 0
Warmup runs: 0

Current
Mean: 0.3 ms
Stdev: 0.5 ms (161.0%)
Runs: 0 0 0 1 0 0 0 1 1 0
Warmup runs: 0
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with default props - 10 runs render Baseline
Mean: 0.1 ms
Stdev: 0.3 ms (316.2%)
Runs: 0 0 0 0 0 0 1 0 0 0
Warmup runs: 1

Current
Mean: 0.2 ms
Stdev: 0.4 ms (210.8%)
Runs: 0 0 1 0 0 0 0 0 0 1
Warmup runs: 1
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with translation key - 10 runs render Baseline
Mean: 0.2 ms
Stdev: 0.4 ms (210.8%)
Runs: 0 1 0 0 0 0 0 0 0 1
Warmup runs: 1

Current
Mean: 0.4 ms
Stdev: 0.5 ms (129.1%)
Runs: 0 1 0 1 0 0 0 1 0 1
Warmup runs: 0
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:
Text Component with weight and size - 10 runs render Baseline
Mean: 0.2 ms
Stdev: 0.4 ms (210.8%)
Runs: 1 0 1 0 0 0 0 0 0 0
Warmup runs: 0

Current
Mean: 0.3 ms
Stdev: 0.5 ms (161.0%)
Runs: 1 1 0 0 0 0 1 0 0 0
Warmup runs: 0
Baseline
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Current
Mean: 1
Stdev: 0 (0.0%)
Runs: 1 1 1 1 1 1 1 1 1 1
Render issues:

Render Count Changes

There are no entries

Render Issues

There are no entries

Added Scenarios

There are no entries

Removed Scenarios

There are no entries

Generated by 🚫 dangerJS against 6d4539e

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
utils/navigation.ts (2)

13-25: Validate ref before setting.
The function checks if the ref is already set or null. Good defensive programming. However, consider whether you want to replace an existing ref if something triggers re-mounting. If replacing the ref is never valid, this is fine as is.


49-51: Refine TypeScript ignore.
Instead of ignoring TypeScript, define a more specific type for the generic navigate method if possible. This ensures type safety around screen names and their params.

- // @ts-ignore
- converseNavigatorRef.navigate(screen, params);
+ // TODO: Provide a more specific type for the navigate method
+ converseNavigatorRef.navigate(
+   screen as keyof NavigationParamList,
+   params as NavigationParamList[keyof NavigationParamList]
+ );
data/store/appStore.ts (1)

90-114: Polling loop for hydration.
This loop polls every 100ms until hydration is complete.
• Consider making the delay configurable.
• Ensure there is a maximum timeout to avoid potential infinite loops.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 70bef63 and 956242a.

📒 Files selected for processing (4)
  • data/store/appStore.ts (2 hunks)
  • features/notifications/utils/onInteractWithNotification.ts (2 hunks)
  • screens/Main.tsx (4 hunks)
  • utils/navigation.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Check: tsc
screens/Main.tsx

[failure] 25-25:
Module '"../utils/navigation"' has no exported member 'converseNavigations'.


[failure] 26-26:
'"../utils/navigation"' has no exported member named 'converseNavigatorRef'. Did you mean 'setConverseNavigatorRef'?

🔇 Additional comments (10)
utils/navigation.ts (3)

8-8: Ensure correct import usage.
Importing the NavigationContainerRef looks correct and aligns well with the rest of the file. No action required.


10-11: Initialize reference to null.
This explicit null initialization is clear and helps avoid referencing an uninitialized ref. No further changes needed.


31-41: Check readiness carefully.
Confirm that any calling code or user interactions don't happen before the navigator is ready. The early returns are good.

features/notifications/utils/onInteractWithNotification.ts (4)

2-2: Consolidate imports.
Imports look consistent, and the new references from "@utils/navigation" are used correctly. No issues found.


7-7: Hydration function usage.
The explicit import of waitForXmtpClientHydration clarifies dependency on app store readiness. This is a clean approach.


13-13: Logging for debugging.
Logging upon interaction with a notification is helpful for troubleshooting. Good practice.


58-58: Awaiting store hydration.
Calling waitForXmtpClientHydration ensures the client is fully ready, preventing race conditions. Well done.

data/store/appStore.ts (1)

5-5: Logger import looks good.
No issues found with importing the logger utility.

screens/Main.tsx (2)

92-95: Logging the ref state.
Logging whether the ref is null helps with debugging. Looks good.


114-114: Splash screen gating.
Properly waiting for splash screen logic to complete before rendering navigation is a neat pattern.

logger.debug(
`[waitForAppStoreHydration] App store hydration not complete, waiting 100ms...`
);
await new Promise((resolve) => setTimeout(resolve, 100));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you doing this vs creating a subscription to the store instead?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I thought about that too. But It would look something like that no? Which isn't cleaner IMO or even much more performant. Maybe we keep what Michael have for now which is good enough IMO.

And we'll probably have to refactor stuff anyway later

const waitForReady = (): Promise<void> => {
  return new Promise((resolve) => {
    const { isReady } = useAccountsStore.getState();
    if (isReady) {
      resolve();
      return;
    }
    const unsubscribe = useAccountsStore.subscribe(
      (state) => state.isReady,
      (ready) => {
        if (ready) {
          resolve();
          unsubscribe(); // Stop listening after `isReady` becomes true
        }
      }
    );
  });
};

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you guys are right I like this better. It would also resolve sooner (rather than waiting for the 100ms window to elapse)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here's a loom with this change: https://www.loom.com/share/d1967df857fb4d1984cbdce195ff7739 (explaining the reason for the wait(1)

@ephemeraHQ ephemeraHQ deleted a comment from coderabbitai bot Dec 19, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (3)
dependencies/Environment/Flavors/determineFlavor.utils.ts (1)

4-8: Temporary Jest check needs clear removal criteria

The TODO comment should specify when and under what conditions this Jest environment check should be removed. Additionally, using @ts-ignore bypasses type safety - consider using proper type guards instead.

Consider this alternative implementation:

-  // todo(lustig): remove this once we have a better way to determine the flavor
-  // @ts-ignore
-  if (typeof jest !== "undefined" || process.env.JEST_WORKER_ID !== undefined) {
+  // TODO(lustig): Remove Jest check after implementing proper test environment detection (TICKET-123)
+  if (
+    (typeof jest !== "undefined" && jest !== null) ||
+    typeof process !== "undefined" && process.env.JEST_WORKER_ID !== undefined
+  ) {
data/store/appStore.ts (1)

105-130: Consider memory leak and error handling improvements

While the implementation is solid, there are two areas for improvement:

  1. The subscription should be cleaned up if the timeout occurs first
  2. The error message could include more diagnostic information

Consider this enhanced implementation:

 export const waitForXmtpClientHydration = (
   timeout: number = 1000
 ): Promise<void> => {
+  let unsubscribe: (() => void) | undefined;
+
   const hydrationPromise = new Promise<void>((resolve) => {
     const { hydrationDone } = useAppStore.getState();
     if (hydrationDone) {
       resolve();
       return;
     }

-    const unsubscribe = useAppStore.subscribe((state, prevState) => {
+    unsubscribe = useAppStore.subscribe((state, prevState) => {
       if (state.hydrationDone && !prevState.hydrationDone) {
         resolve();
         unsubscribe();
       }
     });
   });

   const timeoutPromise = new Promise<void>((_, reject) => {
     setTimeout(() => {
-      reject(new Error("Xmtp client hydration timed out"));
+      if (unsubscribe) {
+        unsubscribe(); // Clean up subscription on timeout
+      }
+      const { hydrationDone } = useAppStore.getState();
+      reject(new Error(
+        `Xmtp client hydration timed out after ${timeout}ms. Current hydration state: ${hydrationDone}`
+      ));
     }, timeout);
   });

   return Promise.race([hydrationPromise, timeoutPromise]);
 };
screens/Main.tsx (1)

88-91: Enhance navigation ref logging

While logging the navigation ref state is helpful, consider including more context for better debugging.

-            logger.info(
-              `[Main] Setting navigation ref to ${r ? "not null" : "null"}`
-            );
+            logger.info(
+              `[Main] Setting navigation ref to ${r ? "not null" : "null"}`,
+              {
+                currentScreen: r?.getCurrentRoute()?.name,
+                timestamp: new Date().toISOString(),
+              }
+            );
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 956242a and 2ebf4f0.

📒 Files selected for processing (3)
  • data/store/appStore.ts (2 hunks)
  • dependencies/Environment/Flavors/determineFlavor.utils.ts (1 hunks)
  • screens/Main.tsx (4 hunks)
🔇 Additional comments (2)
screens/Main.tsx (2)

110-110: LGTM: Simplified state selection

Good job simplifying the state selection to only include the required splashScreenHidden property.


24-24: Verify consistent navigation ref usage

Let's ensure the navigation ref is consistently used across the codebase.

✅ Verification successful

Navigation ref implementation is consistent and well-structured

The navigation ref implementation follows a consistent pattern across the codebase:

  • Central navigation utility in utils/navigation.ts manages the converseNavigatorRef
  • Main screen correctly sets up the navigation ref using setConverseNavigatorRef
  • Navigation references in other components (like ConversationFlashList) are properly scoped
  • Navigation structure is well-organized under dedicated navigation components in the screens/Navigation directory
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for consistent usage of navigation utilities

# Search for direct NavigationContainer ref assignments
echo "Checking for direct ref assignments..."
rg -l "ref={" --type ts --type tsx

# Search for navigation ref usage
echo "Checking navigation ref usage..."
rg "converseNavigatorRef|setConverseNavigatorRef" --type ts --type tsx

# Search for potential navigation-related TODOs
echo "Checking navigation-related TODOs..."
rg "TODO.*navig" --type ts --type tsx

Length of output: 524


Script:

#!/bin/bash
# Let's fix the syntax and search patterns

# Search for navigation ref assignments and usage
echo "Checking navigation patterns..."
rg -i "navigationref|navigatorref" --type-add 'tsx:*.tsx' --type-add 'ts:*.ts'

# Search for navigation utility imports and definitions
echo "Checking navigation utilities..."
rg "setConverseNavigatorRef|converseNavigatorRef" --type-add 'tsx:*.tsx' --type-add 'ts:*.ts'

# Find all navigation-related files
echo "Finding navigation-related files..."
fd -e ts -e tsx | rg -i "navigat"

Length of output: 2707

// note(lustig): this is a hack to ensure that the next render has completed
// as this is used to navigate to a conversation currently.
// We'll revisit this and make something that doesn't suck as much later.
await wait(1);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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";
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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

@@ -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();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
features/GroupInvites/joinGroup/JoinGroup.client.ts (1)

524-526: Consider using a shorter timeout in test fixtures.

The 5-second wait in the test fixture might slow down the test suite unnecessarily.

Consider reducing the timeout:

- await wait(5000);
+ await wait(1000); // 1 second should be sufficient for testing
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2ebf4f0 and 807aff5.

📒 Files selected for processing (2)
  • data/store/appStore.ts (2 hunks)
  • features/GroupInvites/joinGroup/JoinGroup.client.ts (3 hunks)
🔇 Additional comments (3)
data/store/appStore.ts (2)

91-103: LGTM! Well-documented hydration requirements.

The documentation clearly outlines the requirements and current state of XMTP client hydration, which will be valuable for future maintenance and refactoring.


127-131: 🛠️ Refactor suggestion

Consider implementing a more robust solution for render completion.

The current implementation uses a 1ms wait as a temporary solution to ensure render completion. While functional, this approach is fragile and depends on timing assumptions.

Consider implementing one of these alternatives:

  1. Use React's useEffect cleanup or flushSync
  2. Implement a proper render completion callback
  3. Use a state-based approach to track render completion
- // Wait for the next render to complete
- // note(lustig): this is a hack to ensure that the next render has completed
- // as this is used to navigate to a conversation currently.
- // We'll revisit this and make something that doesn't suck as much later.
- await wait(1);
+ // Option 1: Use React's useEffect cleanup
+ await new Promise<void>((resolve) => {
+   const cleanup = useEffect(() => {
+     resolve();
+     return cleanup;
+   }, []);
+ });

Likely invalid or redundant comment.

features/GroupInvites/joinGroup/JoinGroup.client.ts (1)

189-191: LGTM! Consistent use of wait utility.

Good replacement of custom sleep implementation with the shared wait utility, improving code consistency.

logger.info(
`[Main] Setting navigation ref to ${r ? "not null" : "null"}`
);
setConverseNavigatorRef(r);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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

const { splashScreenHidden } = useAppStore(
useSelect(["notificationsPermissionStatus", "splashScreenHidden"])
);
const { splashScreenHidden } = useAppStore(useSelect(["splashScreenHidden"]));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unused

@technoplato technoplato merged commit 19422fc into release/3.0.0 Dec 19, 2024
3 of 5 checks passed
@technoplato technoplato deleted the ml/fix-deeplink-to-groupchat branch December 19, 2024 21:06
@coderabbitai coderabbitai bot mentioned this pull request Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants