Skip to content

Commit da4f2ec

Browse files
committed
fix: don't show twice the connection to the same workspace
Connections started with two different hostnames (because of the ssh wildcard config) can be rendered twice in the Recent projects panel. With this commit we ignore the hostname and instead use the workspace name and deployment URL.
1 parent acc3eba commit da4f2ec

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/main/kotlin/com/coder/gateway/models/RecentWorkspaceConnection.kt

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ class RecentWorkspaceConnection(
8282

8383
other as RecentWorkspaceConnection
8484

85-
if (coderWorkspaceHostname != other.coderWorkspaceHostname) return false
85+
if (name != other.name) return false
86+
if (deploymentURL != other.deploymentURL) return false
8687
if (projectPath != other.projectPath) return false
8788
if (ideProductCode != other.ideProductCode) return false
8889
if (ideBuildNumber != other.ideBuildNumber) return false
@@ -92,7 +93,8 @@ class RecentWorkspaceConnection(
9293

9394
override fun hashCode(): Int {
9495
var result = super.hashCode()
95-
result = 31 * result + (coderWorkspaceHostname?.hashCode() ?: 0)
96+
result = 31 * result + (name?.hashCode() ?: 0)
97+
result = 31 * result + (deploymentURL?.hashCode() ?: 0)
9698
result = 31 * result + (projectPath?.hashCode() ?: 0)
9799
result = 31 * result + (ideProductCode?.hashCode() ?: 0)
98100
result = 31 * result + (ideBuildNumber?.hashCode() ?: 0)
@@ -101,18 +103,21 @@ class RecentWorkspaceConnection(
101103
}
102104

103105
override fun compareTo(other: RecentWorkspaceConnection): Int {
104-
val i = other.coderWorkspaceHostname?.let { coderWorkspaceHostname?.compareTo(it) }
106+
val i = other.name?.let { name?.compareTo(it) }
105107
if (i != null && i != 0) return i
106108

107-
val j = other.projectPath?.let { projectPath?.compareTo(it) }
109+
val j = other.deploymentURL?.let { deploymentURL?.compareTo(it) }
108110
if (j != null && j != 0) return j
109111

110-
val k = other.ideProductCode?.let { ideProductCode?.compareTo(it) }
112+
val k = other.projectPath?.let { projectPath?.compareTo(it) }
111113
if (k != null && k != 0) return k
112114

113-
val l = other.ideBuildNumber?.let { ideBuildNumber?.compareTo(it) }
115+
val l = other.ideProductCode?.let { ideProductCode?.compareTo(it) }
114116
if (l != null && l != 0) return l
115117

118+
val m = other.ideBuildNumber?.let { ideBuildNumber?.compareTo(it) }
119+
if (m != null && m != 0) return m
120+
116121
return 0
117122
}
118123
}

0 commit comments

Comments
 (0)