Skip to content

Commit c4c587e

Browse files
cortinicometa-codesync[bot]
authored andcommitted
DevSupport - fix small bugs with Host change dialog (#54855)
Summary: Pull Request resolved: #54855 I've noticed a couple of bugs with the bundle change dialog: 1. We should not show 2 host change buttons if they're pointing to the same host. 2. The dialog was for some reason writing on `settings.debugServerHost` twice. This has side effects, we should not do it. Changelog: [Android] [Fixed] - DevSupport - fix small bugs with Host change dialog Reviewed By: fabriziocucci Differential Revision: D88952963 fbshipit-source-id: 3fc6c5c342fff1eac663097e64ca1d44b5b7f5a3
1 parent 0fabe26 commit c4c587e

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/ChangeBundleLocationDialog.kt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ internal object ChangeBundleLocationDialog {
3333
) {
3434
val settings = devSettings.packagerConnectionSettings
3535
val currentHost = settings.debugServerHost
36-
settings.debugServerHost = ""
37-
val defaultHost = settings.debugServerHost
38-
settings.debugServerHost = currentHost
3936

4037
val layout = LinearLayout(context)
4138
layout.orientation = LinearLayout.VERTICAL
@@ -60,11 +57,11 @@ internal object ChangeBundleLocationDialog {
6057
input.setTextColor(-0x1000000)
6158
input.setText(currentHost)
6259

63-
val defaultHostSuggestion = Button(context)
64-
defaultHostSuggestion.text = defaultHost
65-
defaultHostSuggestion.textSize = 12f
66-
defaultHostSuggestion.isAllCaps = false
67-
defaultHostSuggestion.setOnClickListener { input.setText(defaultHost) }
60+
val currentHostSuggestion = Button(context)
61+
currentHostSuggestion.text = currentHost
62+
currentHostSuggestion.textSize = 12f
63+
currentHostSuggestion.isAllCaps = false
64+
currentHostSuggestion.setOnClickListener { input.setText(currentHost) }
6865

6966
val networkHost = getDevServerNetworkIpAndPort(context)
7067
val networkHostSuggestion = Button(context)
@@ -80,8 +77,12 @@ internal object ChangeBundleLocationDialog {
8077
LinearLayout.LayoutParams.MATCH_PARENT,
8178
LinearLayout.LayoutParams.WRAP_CONTENT,
8279
)
83-
suggestionRow.addView(defaultHostSuggestion)
84-
suggestionRow.addView(networkHostSuggestion)
80+
suggestionRow.addView(currentHostSuggestion)
81+
82+
if (currentHost != networkHost) {
83+
// We don't want to display two buttons with the same host suggestion.
84+
suggestionRow.addView(networkHostSuggestion)
85+
}
8586

8687
val instructions = TextView(context)
8788
instructions.text =

0 commit comments

Comments
 (0)