remove redundant method from MountItemDispatcher (#41061)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41061

changelog: [internal]

Method `dispatchCommandMountItem` only calls `addViewCommandMountItem`  without adding anything on top of it. The name is inaccurate because it doesn't dispatch mount item, it queues it.

Let's remove one of them to simplify the API.

Reviewed By: javache

Differential Revision: D50408576

fbshipit-source-id: 3a4871c38e7b081a5e27aba211d61254075e76cd
This commit is contained in:
Samuel Susla
2023-10-19 04:53:25 -07:00
committed by Facebook GitHub Bot
parent c9d3289222
commit 4134d8db01
2 changed files with 7 additions and 15 deletions
@@ -1023,7 +1023,7 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
final int reactTag,
final int commandId,
@Nullable final ReadableArray commandArgs) {
mMountItemDispatcher.dispatchCommandMountItem(
mMountItemDispatcher.addViewCommandMountItem(
MountItemFactory.createDispatchCommandMountItem(
surfaceId, reactTag, commandId, commandArgs));
}
@@ -1039,10 +1039,10 @@ public class FabricUIManager implements UIManager, LifecycleEventListener {
// For Fabric Interop, we check if the commandId is an integer. If it is, we use the integer
// overload of dispatchCommand. Otherwise, we use the string overload.
// and the events won't be correctly dispatched.
mMountItemDispatcher.dispatchCommandMountItem(
mMountItemDispatcher.addViewCommandMountItem(
createDispatchCommandMountItemForInterop(surfaceId, reactTag, commandId, commandArgs));
} else {
mMountItemDispatcher.dispatchCommandMountItem(
mMountItemDispatcher.addViewCommandMountItem(
MountItemFactory.createDispatchCommandMountItem(
surfaceId, reactTag, commandId, commandArgs));
}
@@ -7,14 +7,12 @@
package com.facebook.react.fabric.mounting;
import static com.facebook.infer.annotation.ThreadConfined.ANY;
import static com.facebook.infer.annotation.ThreadConfined.UI;
import static com.facebook.react.fabric.FabricUIManager.ENABLE_FABRIC_LOGS;
import static com.facebook.react.fabric.FabricUIManager.IS_DEVELOPMENT_ENVIRONMENT;
import android.os.SystemClock;
import android.view.View;
import androidx.annotation.AnyThread;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.UiThread;
@@ -62,10 +60,8 @@ public class MountItemDispatcher {
mItemDispatchListener = listener;
}
@AnyThread
@ThreadConfined(ANY)
public void dispatchCommandMountItem(DispatchCommandMountItem command) {
addViewCommandMountItem(command);
public void addViewCommandMountItem(DispatchCommandMountItem mountItem) {
mViewCommandMountItems.add(mountItem);
}
public void addMountItem(MountItem mountItem) {
@@ -88,10 +84,6 @@ public class MountItemDispatcher {
}
}
public void addViewCommandMountItem(DispatchCommandMountItem mountItem) {
mViewCommandMountItems.add(mountItem);
}
/**
* Try to dispatch MountItems. In case of the exception, we will retry 10 times before giving up.
*/
@@ -159,7 +151,7 @@ public class MountItemDispatcher {
mountItem.incrementRetries();
// In case we haven't retried executing this item yet, execute in the next batch of
// items
dispatchCommandMountItem(mountItem);
addViewCommandMountItem(mountItem);
}
} else {
printMountItem(
@@ -214,7 +206,7 @@ public class MountItemDispatcher {
// the current batch of mount items has finished executing.
if (command.getRetries() == 0) {
command.incrementRetries();
dispatchCommandMountItem(command);
addViewCommandMountItem(command);
} else {
// It's very common for commands to be executed on views that no longer exist - for
// example, a blur event on TextInput being fired because of a navigation event away