refactor: remove verified dead code across data, UI, and resources (#680)
* refactor: remove unused dead code across data, UI, and resources * fix: resolve dangling references left by dead-code removal Restore empty object Motion (braces required) and remove the 12 stale test usages that still called the now-deleted production symbols: - ServerStoreTest: removeServer/switchToServer tests - ServerEndpointTest: isCleartext assertions - ConnectViewModelTest: onHostChange/onPortChange tests + 3 dropped R.string refs - SettingsViewModelTest: renameProfile tests + clearNavigateToLogin - E2eIntegrationTest: previewSkill tests + onHostChange/onPortChange calls Verified locally: compileDebugUnitTestKotlin + 48 tests pass. * fix: remove unused imports flagged by ktlint Drops 4 no-longer-referenced imports left by the dead-code removal: - HermesApiService: SkillScanResponse (scanHubSkill removed) - ServerEndpointTest: assertFalse, assertTrue (isCleartext assertions dropped) - SettingsViewModelTest: assertFalse (rename tests removed) --------- Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
1 parent
58420d7b2a
commit
2e97ee9a84
29 files changed
+10
-550
No files matched your search
@@ -8,14 +8,6 @@ fun ServerStoreState.addOrReplaceServer(profile: ConnectionProfile): ServerStore
|
||||
return copy(connectionProfiles = updated)
|
||||
}
|
||||
|
||||
fun ServerStoreState.removeServer(id: String): ServerStoreState {
|
||||
val updated = connectionProfiles.filter { it.id != id }
|
||||
val newSelected = if (selectedProfileId == id) null else selectedProfileId
|
||||
return copy(connectionProfiles = updated, selectedProfileId = newSelected)
|
||||
}
|
||||
|
||||
fun ServerStoreState.switchToServer(id: String?): ServerStoreState = copy(selectedProfileId = id)
|
||||
|
||||
fun ServerStoreState.selfHealed(): ServerStoreState {
|
||||
val hasActive = connectionProfiles.any { it.id == selectedProfileId }
|
||||
val newSelected = if (selectedProfileId != null && !hasActive) null else selectedProfileId
|
||||
|
||||
@@ -5,7 +5,6 @@ import androidx.datastore.core.Serializer
|
||||
import com.m57.hermescontrol.data.remote.ServerEndpoint
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
import kotlinx.coroutines.flow.asStateFlow
|
||||
@@ -22,7 +21,6 @@ class ServerStore(
|
||||
) {
|
||||
private val _stateFlow: MutableStateFlow<ServerStoreState>
|
||||
val stateFlow: StateFlow<ServerStoreState>
|
||||
val state: Flow<ServerStoreState>
|
||||
|
||||
init {
|
||||
val initial =
|
||||
@@ -35,7 +33,6 @@ class ServerStore(
|
||||
}
|
||||
_stateFlow = MutableStateFlow(initial)
|
||||
stateFlow = _stateFlow.asStateFlow()
|
||||
state = stateFlow
|
||||
}
|
||||
|
||||
fun getLatestState(): ServerStoreState = _stateFlow.value
|
||||
|
||||
@@ -450,18 +450,6 @@ object AuthManager {
|
||||
|
||||
fun getPort(): Int = serverStore.getLatestState().resolvedPort
|
||||
|
||||
fun setHost(host: String) {
|
||||
val endpoint = endpoint()
|
||||
val normalizedHost = host.trim().removePrefix("[").removeSuffix("]")
|
||||
setBaseUrl(endpoint.baseUrl.newBuilder().host(normalizedHost).build().toString())
|
||||
}
|
||||
|
||||
fun setPort(port: Int) {
|
||||
require(port in 1..65535) { "Port is out of range" }
|
||||
val endpoint = endpoint()
|
||||
setBaseUrl(endpoint.baseUrl.newBuilder().port(port).build().toString())
|
||||
}
|
||||
|
||||
// ── Auto-reconnect ───────────────────────────────────────────────────
|
||||
|
||||
fun isAutoReconnect(): Boolean = serverStore.getLatestState().autoReconnect
|
||||
|
||||
@@ -125,11 +125,6 @@ data class UsageBar(
|
||||
|
||||
// ── subscription.preview ──────────────────────────────────────────────────
|
||||
|
||||
@Serializable
|
||||
data class SubscriptionPreviewRequest(
|
||||
val subscription_type_id: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SubscriptionPreviewResponse(
|
||||
val ok: Boolean? = null,
|
||||
@@ -184,11 +179,6 @@ data class SubscriptionResumeResponse(
|
||||
|
||||
// ── subscription.upgrade ──────────────────────────────────────────────────
|
||||
|
||||
@Serializable
|
||||
data class SubscriptionUpgradeRequest(
|
||||
val subscription_type_id: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
data class SubscriptionUpgradeResponse(
|
||||
val ok: Boolean? = null,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.m57.hermescontrol.data.remote
|
||||
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.decodeFromString
|
||||
import kotlinx.serialization.encodeToString
|
||||
|
||||
@Serializable
|
||||
@@ -12,11 +11,6 @@ private data class PasswordLoginPayload(
|
||||
val next: String,
|
||||
)
|
||||
|
||||
@Serializable
|
||||
private data class WebSocketTicketPayload(
|
||||
val ticket: String,
|
||||
)
|
||||
|
||||
/** JSON serialization for authentication requests and responses. */
|
||||
object AuthPayloads {
|
||||
fun passwordLogin(
|
||||
@@ -31,11 +25,4 @@ object AuthPayloads {
|
||||
next = "",
|
||||
),
|
||||
)
|
||||
|
||||
fun webSocketTicket(body: String): String? =
|
||||
runCatching {
|
||||
OkHttpProvider.json.decodeFromString<WebSocketTicketPayload>(body)
|
||||
.ticket
|
||||
.takeIf { it.isNotBlank() }
|
||||
}.getOrNull()
|
||||
}
|
||||
@@ -77,13 +77,6 @@ fun wrapSessionCookie(rawValue: String): Cookie? {
|
||||
}.getOrNull()
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a permissive [Cookie] from a Set-Cookie `hermes_session_at=...`
|
||||
* header captured during login. Used by [PersistentCookieJar] when the server
|
||||
* does not echo an explicit domain (common for same-host dashboard logins).
|
||||
*/
|
||||
fun sessionCookieFromValue(value: String): Cookie? = wrapSessionCookie(value)
|
||||
|
||||
const val SESSION_COOKIE_NAME = "hermes_session_at"
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,7 +76,6 @@ import com.m57.hermescontrol.data.model.SkillContentResponse
|
||||
import com.m57.hermescontrol.data.model.SkillHubInstallRequest
|
||||
import com.m57.hermescontrol.data.model.SkillHubSearchResponse
|
||||
import com.m57.hermescontrol.data.model.SkillHubUninstallRequest
|
||||
import com.m57.hermescontrol.data.model.SkillScanResponse
|
||||
import com.m57.hermescontrol.data.model.StatusResponse
|
||||
import com.m57.hermescontrol.data.model.SystemStatsResponse
|
||||
import com.m57.hermescontrol.data.model.TelegramOnboardingApplyRequest
|
||||
@@ -211,14 +210,6 @@ interface HermesApiService {
|
||||
@Query("identifier") identifier: String,
|
||||
): Response<SkillContentResponse>
|
||||
|
||||
@GET("api/skills/hub/scan")
|
||||
suspend fun scanHubSkill(
|
||||
@Query("identifier") identifier: String,
|
||||
): Response<SkillScanResponse>
|
||||
|
||||
@GET("api/skills/hub/sources")
|
||||
suspend fun getHubSources(): Response<List<String>>
|
||||
|
||||
@POST("api/skills/hub/install")
|
||||
suspend fun installHubSkill(
|
||||
@Body body: SkillHubInstallRequest,
|
||||
|
||||
@@ -21,9 +21,6 @@ class ServerEndpoint private constructor(
|
||||
val baseUrl: HttpUrl,
|
||||
val securityWarning: String?,
|
||||
) {
|
||||
val isCleartext: Boolean
|
||||
get() = baseUrl.scheme == "http"
|
||||
|
||||
fun resolve(relativePath: String): HttpUrl {
|
||||
val path = relativePath.trim().trimStart('/')
|
||||
require(path.isNotEmpty()) { "Endpoint path must not be blank" }
|
||||
|
||||
@@ -24,7 +24,6 @@ object WsMethods {
|
||||
// ── Commands catalog ──────────────────────────────────────────────────
|
||||
const val COMMANDS_CATALOG = "commands.catalog"
|
||||
const val COMMAND_DISPATCH = "command.dispatch"
|
||||
const val COMMAND_RESOLVE = "command.resolve"
|
||||
const val SLASH_EXEC = "slash.exec"
|
||||
const val CONFIG_SET = "config.set"
|
||||
|
||||
|
||||
Reference in new issue
Block a user