Skip to content

Conversation

@chrissiewasabi
Copy link
Contributor

No description provided.

@chrissiewasabi chrissiewasabi changed the title sc-167747:Refactor showInAppMessage to properly handle suspend function [sc-167747]:Refactor showInAppMessage to properly handle suspend function Sep 3, 2025
@chrissiewasabi chrissiewasabi changed the title [sc-167747]:Refactor showInAppMessage to properly handle suspend function [SC-167747]:Refactor showInAppMessage to properly handle suspend function Sep 3, 2025
@chayelheinsen chayelheinsen changed the title [SC-167747]:Refactor showInAppMessage to properly handle suspend function Refactor showInAppMessage to properly handle suspend function [SC-167747] Sep 3, 2025
@chayelheinsen chayelheinsen merged commit d5d0ad6 into main Sep 3, 2025
4 checks passed
@chayelheinsen chayelheinsen deleted the sc-167747 branch September 3, 2025 13:48
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the showInAppMessage method in the Android SDK to properly handle suspend functions by using coroutines and lifecycle-aware components. The refactor addresses proper coroutine handling for asynchronous operations while adding error handling.

  • Wrapped the MIClient.showInAppBrowser call in a coroutine scope to handle suspend functions properly
  • Added lifecycle-aware coroutine launching using lifecycleScope
  • Enhanced error handling with try-catch block and proper UI thread callback execution

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
package.json Version bump from 2.1.0 to 2.1.1
RNMovableInkModule.kt Refactored showInAppMessage to use coroutines with lifecycle scope and added error handling
build.gradle Added androidx.lifecycle:lifecycle-runtime-ktx dependency for lifecycle-aware coroutines

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +90 to +91
val activity = currentActivity
if (activity is androidx.lifecycle.LifecycleOwner) {
Copy link

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

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

Missing else branch to handle the case when activity is not a LifecycleOwner. The callback should be invoked with an error message to prevent the caller from waiting indefinitely.

Copilot uses AI. Check for mistakes.
callback.invoke(value)
@ReactMethod
fun showInAppMessage(url: String, callback: Callback) {
val activity = currentActivity
Copy link

Copilot AI Sep 3, 2025

Choose a reason for hiding this comment

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

Missing null check for currentActivity. If currentActivity is null, the callback should be invoked with an error message to handle this edge case properly.

Suggested change
val activity = currentActivity
val activity = currentActivity
if (activity == null) {
callback.invoke("Error: currentActivity is null")
return
}

Copilot uses AI. Check for mistakes.
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