Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode VERSIONCODE as Integer
versionName "4.68.1"
versionName "4.68.2"
vectorDrawables.useSupportLibrary = true
manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String]
resValue "string", "rn_config_reader_custom_package", "chat.rocket.reactnative"
Expand Down
56 changes: 7 additions & 49 deletions android/app/src/main/java/chat/rocket/reactnative/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import android.os.Bundle
import com.zoontek.rnbootsplash.RNBootSplash
import android.content.Intent
import android.content.res.Configuration
import chat.rocket.reactnative.notification.VideoConfModule
import chat.rocket.reactnative.notification.VideoConfNotification
import com.google.gson.GsonBuilder
import chat.rocket.reactnative.notification.NotificationIntentHandler

class MainActivity : ReactActivity() {

Expand All @@ -32,56 +30,16 @@ class MainActivity : ReactActivity() {
RNBootSplash.init(this, R.style.BootTheme)
super.onCreate(null)

// Handle video conf action from notification
intent?.let { handleVideoConfIntent(it) }
// Handle notification intents
intent?.let { NotificationIntentHandler.handleIntent(this, it) }
Comment on lines +33 to +34
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Find NotificationIntentHandler implementation
fd -e kt NotificationIntentHandler --exec cat {}

Repository: RocketChat/Rocket.Chat.ReactNative

Length of output: 6524


Add error handling to handleVideoConfIntent method.

The handleNotificationIntent has good error handling, but handleVideoConfIntent lacks protection around the VideoConfModule.storePendingAction call. If this throws an exception, it will bubble up and prevent onCreate from completing. Wrap the storage operation in a try-catch block similar to the handleNotificationIntent implementation to ensure robustness during activity initialization.

🤖 Prompt for AI Agents
In @android/app/src/main/java/chat/rocket/reactnative/MainActivity.kt around
lines 33 - 34, The handleVideoConfIntent path should mirror the error handling
used for notification intents: wrap the call to
VideoConfModule.storePendingAction (invoked from MainActivity.onCreate or the
helper handling video-conf intents) in a try-catch that catches Exception and
logs it via the same logger used for notifications, ensuring any thrown error
does not propagate and block onCreate; locate the call to
VideoConfModule.storePendingAction and add the protective try-catch around it
with an informative error log message.

}

public override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
// Handle video conf action when activity is already running
handleVideoConfIntent(intent)
}

private fun handleVideoConfIntent(intent: Intent) {
if (intent.getBooleanExtra("videoConfAction", false)) {
val notificationId = intent.getIntExtra("notificationId", 0)
val event = intent.getStringExtra("event") ?: return
val rid = intent.getStringExtra("rid") ?: ""
val callerId = intent.getStringExtra("callerId") ?: ""
val callerName = intent.getStringExtra("callerName") ?: ""
val host = intent.getStringExtra("host") ?: ""
val callId = intent.getStringExtra("callId") ?: ""

android.util.Log.d("RocketChat.MainActivity", "Handling video conf intent - event: $event, rid: $rid, host: $host, callId: $callId")

// Cancel the notification
if (notificationId != 0) {
VideoConfNotification.cancelById(this, notificationId)
}

// Store action for JS to pick up - include all required fields
val data = mapOf(
"notificationType" to "videoconf",
"rid" to rid,
"event" to event,
"host" to host,
"callId" to callId,
"caller" to mapOf(
"_id" to callerId,
"name" to callerName
)
)

val gson = GsonBuilder().create()
val jsonData = gson.toJson(data)

android.util.Log.d("RocketChat.MainActivity", "Storing video conf action: $jsonData")

VideoConfModule.storePendingAction(this, jsonData)

// Clear the video conf flag to prevent re-processing
intent.removeExtra("videoConfAction")
}
setIntent(intent)

// Handle notification intents when activity is already running
NotificationIntentHandler.handleIntent(this, intent)
}

override fun invokeDefaultOnBackPressed() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ import android.content.res.Configuration
import com.facebook.react.PackageList
import com.facebook.react.ReactApplication
import com.facebook.react.ReactHost
import com.facebook.react.ReactInstanceEventListener
import com.facebook.react.ReactNativeHost
import com.facebook.react.ReactPackage
import com.facebook.react.bridge.ReactContext
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint.load
import com.facebook.react.defaults.DefaultReactHost.getDefaultReactHost
import com.facebook.react.defaults.DefaultReactNativeHost
Expand All @@ -21,8 +18,8 @@ import expo.modules.ApplicationLifecycleDispatcher
import chat.rocket.reactnative.networking.SSLPinningTurboPackage;
import chat.rocket.reactnative.storage.MMKVKeyManager;
import chat.rocket.reactnative.storage.SecureStoragePackage;
import chat.rocket.reactnative.notification.CustomPushNotification;
import chat.rocket.reactnative.notification.VideoConfTurboPackage
import chat.rocket.reactnative.notification.PushNotificationTurboPackage

/**
* Main Application class.
Expand All @@ -45,6 +42,7 @@ open class MainApplication : Application(), ReactApplication {
add(SSLPinningTurboPackage())
add(WatermelonDBJSIPackage())
add(VideoConfTurboPackage())
add(PushNotificationTurboPackage())
add(SecureStoragePackage())
}

Expand All @@ -71,13 +69,6 @@ open class MainApplication : Application(), ReactApplication {
// Load the native entry point for the New Architecture
load()

// Register listener to set React context when initialized
reactHost.addReactInstanceEventListener(object : ReactInstanceEventListener {
override fun onReactContextInitialized(context: ReactContext) {
CustomPushNotification.setReactContext(context as ReactApplicationContext)
}
})

ApplicationLifecycleDispatcher.onApplicationCreate(this)
}

Expand Down
Loading
Loading