diff --git a/backend/services/identity/identity-domain/src/main/kotlin/at/mocode/identity/domain/model/Device.kt b/backend/services/identity/identity-domain/src/main/kotlin/at/mocode/identity/domain/model/Device.kt index b10250c9..292e21ab 100644 --- a/backend/services/identity/identity-domain/src/main/kotlin/at/mocode/identity/domain/model/Device.kt +++ b/backend/services/identity/identity-domain/src/main/kotlin/at/mocode/identity/domain/model/Device.kt @@ -1,7 +1,7 @@ package at.mocode.identity.domain.model -import kotlinx.datetime.Instant import java.util.* +import kotlin.time.Instant /** * Repräsentiert eine registrierte Desktop-Instanz ("Gerät"). @@ -13,7 +13,8 @@ data class Device( val securityKeyHash: String, // Gehasht für Sicherheit val role: DeviceRole = DeviceRole.CLIENT, val lastSyncAt: Instant? = null, - val createdAt: Instant + val createdAt: Instant, + val updatedAt: Instant = createdAt ) enum class DeviceRole { diff --git a/backend/services/identity/identity-domain/src/main/kotlin/at/mocode/identity/domain/repository/DeviceRepository.kt b/backend/services/identity/identity-domain/src/main/kotlin/at/mocode/identity/domain/repository/DeviceRepository.kt index 024999cd..58964615 100644 --- a/backend/services/identity/identity-domain/src/main/kotlin/at/mocode/identity/domain/repository/DeviceRepository.kt +++ b/backend/services/identity/identity-domain/src/main/kotlin/at/mocode/identity/domain/repository/DeviceRepository.kt @@ -1,8 +1,8 @@ package at.mocode.identity.domain.repository import at.mocode.identity.domain.model.Device -import kotlinx.datetime.Instant import java.util.* +import kotlin.time.Instant interface DeviceRepository { suspend fun findById(id: UUID): Device? diff --git a/backend/services/identity/identity-infrastructure/src/main/kotlin/at/mocode/identity/infrastructure/persistence/ExposedDeviceRepository.kt b/backend/services/identity/identity-infrastructure/src/main/kotlin/at/mocode/identity/infrastructure/persistence/ExposedDeviceRepository.kt index d3692d33..57ef8bde 100644 --- a/backend/services/identity/identity-infrastructure/src/main/kotlin/at/mocode/identity/infrastructure/persistence/ExposedDeviceRepository.kt +++ b/backend/services/identity/identity-infrastructure/src/main/kotlin/at/mocode/identity/infrastructure/persistence/ExposedDeviceRepository.kt @@ -11,7 +11,6 @@ import org.jetbrains.exposed.v1.jdbc.update import java.util.* import kotlin.time.Clock import kotlin.time.Instant -import kotlin.time.toJavaInstant class ExposedDeviceRepository : DeviceRepository { @@ -36,8 +35,8 @@ class ExposedDeviceRepository : DeviceRepository { it[name] = device.name it[securityKeyHash] = device.securityKeyHash it[role] = device.role - it[lastSyncAt] = device.lastSyncAt?.toJavaInstant() - it[updatedAt] = now.toJavaInstant() + it[lastSyncAt] = device.lastSyncAt + it[updatedAt] = now } } else { DeviceTable.insert { @@ -45,19 +44,18 @@ class ExposedDeviceRepository : DeviceRepository { it[name] = device.name it[securityKeyHash] = device.securityKeyHash it[role] = device.role - it[lastSyncAt] = device.lastSyncAt?.toJavaInstant() - it[createdAt] = now.toJavaInstant() - it[updatedAt] = now.toJavaInstant() + it[lastSyncAt] = device.lastSyncAt + it[createdAt] = device.createdAt + it[updatedAt] = now } } - device + device.copy(updatedAt = now) } override suspend fun updateLastSyncAt(id: UUID, at: Instant): Boolean = transaction { - val javaInstant = at.toJavaInstant() DeviceTable.update({ DeviceTable.id eq id }) { - it[lastSyncAt] = javaInstant - it[updatedAt] = javaInstant + it[lastSyncAt] = at + it[updatedAt] = at } > 0 } @@ -66,7 +64,8 @@ class ExposedDeviceRepository : DeviceRepository { name = row[DeviceTable.name], securityKeyHash = row[DeviceTable.securityKeyHash], role = row[DeviceTable.role], - lastSyncAt = row[DeviceTable.lastSyncAt]?.let { Instant.fromEpochMilliseconds(it.toEpochMilli()) }, - createdAt = Instant.fromEpochMilliseconds(row[DeviceTable.createdAt].toEpochMilli()) + lastSyncAt = row[DeviceTable.lastSyncAt], + createdAt = row[DeviceTable.createdAt], + updatedAt = row[DeviceTable.updatedAt] ) } diff --git a/frontend/features/turnier-feature/src/jvmMain/kotlin/at/mocode/turnier/feature/presentation/TurnierStammdatenTab.kt b/frontend/features/turnier-feature/src/jvmMain/kotlin/at/mocode/turnier/feature/presentation/TurnierStammdatenTab.kt index b8421ef9..fe119c43 100644 --- a/frontend/features/turnier-feature/src/jvmMain/kotlin/at/mocode/turnier/feature/presentation/TurnierStammdatenTab.kt +++ b/frontend/features/turnier-feature/src/jvmMain/kotlin/at/mocode/turnier/feature/presentation/TurnierStammdatenTab.kt @@ -100,7 +100,10 @@ fun StammdatenTabContent( val katField = tClass.getDeclaredField("kategorie") katField.isAccessible = true val kats = katField.get(turnier) as? List - kats?.let { kat.addAll(it) } + kats?.let { + kat.clear() + kat.addAll(it) + } val typField = tClass.getDeclaredField("typ") typField.isAccessible = true