Skip to content

Commit

Permalink
fix timelineaction deserialization for notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
crc-32 committed Jul 3, 2024
1 parent 1982609 commit e8125a4
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion android/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ gradle = "8.5.0"
koinVersion = "3.2.0"
kotlin = "2.0.20-Beta1"
kotlinxDatetime = "0.6.0"
kotlinxSerializationJson = "1.7.0"
kotlinxSerializationJson = "1.7.1"
ksp = "2.0.20-Beta1-1.0.22"
libpebblecommonVersion = "0.1.20"

Expand Down
2 changes: 1 addition & 1 deletion android/shared/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ kotlin {
implementation("com.github.PhilJay:RRule:$rruleVersion")
}
commonTest.dependencies {
implementation(kotlin("test-common"))
implementation(kotlin("test"))
}
}
room {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ object TimelineActionTypeSerializer : KSerializer<TimelineItem.Action.Type> {
}

override fun deserialize(decoder: Decoder): TimelineItem.Action.Type {
return TimelineItem.Action.Type.entries.first { it.value.toInt() == decoder.decodeInt() }
val raw = decoder.decodeInt()
return TimelineItem.Action.Type.entries.first { it.value.toInt() == raw}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.rebble.cobble.data

import io.rebble.cobble.shared.data.TimelineAction
import io.rebble.libpebblecommon.packets.blobdb.TimelineItem
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlin.test.Test
import kotlin.test.assertEquals

class TimelineActionTest {
@Test
fun test() {
val action = TimelineAction(1, TimelineItem.Action.Type.Generic, emptyList())
val json = Json.encodeToString(action)
println(json)
val deserialized = Json.decodeFromString(TimelineAction.serializer(), json)
println(deserialized)
assertEquals(action, deserialized)
}
}

0 comments on commit e8125a4

Please sign in to comment.