chore: upgrade ktlint to 1.8.0 and format codebase (#1024)
Co-authored-by: M57 <hy4ri@users.noreply.github.com>
This commit is contained in:
1 parent
3f3b853758
commit
cfe3e736fd
66 files changed
+1287
-541
No files matched your search
@@ -239,13 +239,14 @@ data class GroupChatRoomMeta(
|
||||
) {
|
||||
val memberNames: List<String>
|
||||
get() =
|
||||
members?.mapNotNull { el ->
|
||||
when (el) {
|
||||
is JsonPrimitive -> el.content
|
||||
is JsonObject -> el["name"]?.jsonPrimitive?.content ?: el["handle"]?.jsonPrimitive?.content
|
||||
else -> null
|
||||
}
|
||||
}.orEmpty()
|
||||
members
|
||||
?.mapNotNull { el ->
|
||||
when (el) {
|
||||
is JsonPrimitive -> el.content
|
||||
is JsonObject -> el["name"]?.jsonPrimitive?.content ?: el["handle"]?.jsonPrimitive?.content
|
||||
else -> null
|
||||
}
|
||||
}.orEmpty()
|
||||
}
|
||||
|
||||
@Serializable
|
||||
|
||||
@@ -76,7 +76,9 @@ object GatewayFileClient {
|
||||
token: String,
|
||||
path: String,
|
||||
): String? {
|
||||
val kind = com.m57.hermescontrol.ui.chat.mediaKindForPath(path)
|
||||
val kind =
|
||||
com.m57.hermescontrol.ui.chat
|
||||
.mediaKindForPath(path)
|
||||
val endpoint =
|
||||
if (kind == com.m57.hermescontrol.ui.chat.MediaKind.AUDIO ||
|
||||
kind == com.m57.hermescontrol.ui.chat.MediaKind.VIDEO
|
||||
|
||||
@@ -23,11 +23,21 @@ fun isLocalNetworkHost(host: String): Boolean {
|
||||
val a = raw[0].toInt() and 0xFF
|
||||
val b = raw[1].toInt() and 0xFF
|
||||
return when {
|
||||
a == 10 -> true // 10.0.0.0/8
|
||||
a == 172 && b in 16..31 -> true // 172.16.0.0/12
|
||||
a == 192 && b == 168 -> true // 192.168.0.0/16
|
||||
a == 169 && b == 254 -> true // 169.254.0.0/16 link-local
|
||||
a == 100 && b in 64..127 -> true // 100.64.0.0/10 CGNAT
|
||||
a == 10 -> true
|
||||
|
||||
// 10.0.0.0/8
|
||||
a == 172 && b in 16..31 -> true
|
||||
|
||||
// 172.16.0.0/12
|
||||
a == 192 && b == 168 -> true
|
||||
|
||||
// 192.168.0.0/16
|
||||
a == 169 && b == 254 -> true
|
||||
|
||||
// 169.254.0.0/16 link-local
|
||||
a == 100 && b in 64..127 -> true
|
||||
|
||||
// 100.64.0.0/10 CGNAT
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,9 @@ sealed interface AppUpdateState {
|
||||
data object Checking : AppUpdateState
|
||||
|
||||
/** Latest release equals the installed version. */
|
||||
data class UpToDate(val latestTag: String) : AppUpdateState
|
||||
data class UpToDate(
|
||||
val latestTag: String,
|
||||
) : AppUpdateState
|
||||
|
||||
/** A newer release with an APK asset exists. */
|
||||
data class UpdateAvailable(
|
||||
@@ -24,15 +26,21 @@ sealed interface AppUpdateState {
|
||||
) : AppUpdateState
|
||||
|
||||
/** APK download in progress; [progress] is 0..1. */
|
||||
data class Downloading(val progress: Float) : AppUpdateState
|
||||
data class Downloading(
|
||||
val progress: Float,
|
||||
) : AppUpdateState
|
||||
|
||||
/** Download finished and the system package installer was launched. */
|
||||
data class Installing(val latestTag: String) : AppUpdateState
|
||||
data class Installing(
|
||||
val latestTag: String,
|
||||
) : AppUpdateState
|
||||
|
||||
/** Install-from-unknown-sources not granted for this app yet. */
|
||||
data object NeedsUnknownSourcesPermission : AppUpdateState
|
||||
|
||||
data class Error(val message: String) : AppUpdateState
|
||||
data class Error(
|
||||
val message: String,
|
||||
) : AppUpdateState
|
||||
}
|
||||
|
||||
/** The release tag a state carries, when it carries one. */
|
||||
|
||||
@@ -256,12 +256,15 @@ object HermesWsClient {
|
||||
is WsEvent.ThinkingDelta,
|
||||
is WsEvent.ReasoningDelta,
|
||||
is WsEvent.ToolStart,
|
||||
-> pendingReply = true
|
||||
-> {
|
||||
pendingReply = true
|
||||
}
|
||||
|
||||
is WsEvent.MessageComplete -> {
|
||||
pendingReply = false
|
||||
disconnectIfIdleInBackground()
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
@@ -992,7 +995,9 @@ object HermesWsClient {
|
||||
disconnectIfIdleInBackground()
|
||||
}
|
||||
|
||||
else -> Unit
|
||||
else -> {
|
||||
Unit
|
||||
}
|
||||
}
|
||||
// tryEmit on a DROP_OLDEST flow only returns false when the
|
||||
// buffer is full AND no subscriber is draining; with extraBuffer=512
|
||||
|
||||
@@ -44,12 +44,30 @@ data class JsonRpcError(
|
||||
|
||||
fun Any?.toJsonElement(): JsonElement =
|
||||
when (this) {
|
||||
null -> JsonNull
|
||||
is JsonElement -> this
|
||||
is Boolean -> JsonPrimitive(this)
|
||||
is Int -> JsonPrimitive(this)
|
||||
is Long -> JsonPrimitive(this)
|
||||
is Float -> JsonPrimitive(this)
|
||||
null -> {
|
||||
JsonNull
|
||||
}
|
||||
|
||||
is JsonElement -> {
|
||||
this
|
||||
}
|
||||
|
||||
is Boolean -> {
|
||||
JsonPrimitive(this)
|
||||
}
|
||||
|
||||
is Int -> {
|
||||
JsonPrimitive(this)
|
||||
}
|
||||
|
||||
is Long -> {
|
||||
JsonPrimitive(this)
|
||||
}
|
||||
|
||||
is Float -> {
|
||||
JsonPrimitive(this)
|
||||
}
|
||||
|
||||
is Double -> {
|
||||
// Preserve integer semantics: 177.0 → JsonPrimitive(177) not "177.0"
|
||||
if (this % 1.0 == 0.0 && this >= Int.MIN_VALUE.toDouble() && this <= Int.MAX_VALUE.toDouble()) {
|
||||
@@ -60,11 +78,26 @@ fun Any?.toJsonElement(): JsonElement =
|
||||
JsonPrimitive(this)
|
||||
}
|
||||
}
|
||||
is Number -> JsonPrimitive(this)
|
||||
is String -> JsonPrimitive(this)
|
||||
is Map<*, *> -> JsonObject(this.map { it.key.toString() to it.value.toJsonElement() }.toMap())
|
||||
is List<*> -> JsonArray(this.map { it.toJsonElement() })
|
||||
else -> JsonPrimitive(this.toString())
|
||||
|
||||
is Number -> {
|
||||
JsonPrimitive(this)
|
||||
}
|
||||
|
||||
is String -> {
|
||||
JsonPrimitive(this)
|
||||
}
|
||||
|
||||
is Map<*, *> -> {
|
||||
JsonObject(this.map { it.key.toString() to it.value.toJsonElement() }.toMap())
|
||||
}
|
||||
|
||||
is List<*> -> {
|
||||
JsonArray(this.map { it.toJsonElement() })
|
||||
}
|
||||
|
||||
else -> {
|
||||
JsonPrimitive(this.toString())
|
||||
}
|
||||
}
|
||||
|
||||
fun JsonElement.toAny(): Any? =
|
||||
|
||||
Reference in new issue
Block a user