diff options
author | Robert Jaros <rjaros@finn.pl> | 2018-09-28 13:08:57 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2018-09-28 13:08:57 +0200 |
commit | 1c021517808829418ac9bc8443e6b2653c869812 (patch) | |
tree | f9b626f24a2969f669ab2d939b6cd31a0d063d32 /src/main/kotlin/pl | |
parent | a3bfbe7f072217288c14e3f2c734bb5918564c33 (diff) | |
download | kvision-1c021517808829418ac9bc8443e6b2653c869812.tar.gz kvision-1c021517808829418ac9bc8443e6b2653c869812.tar.bz2 kvision-1c021517808829418ac9bc8443e6b2653c869812.zip |
Migration to Kotlin 1.3
Diffstat (limited to 'src/main/kotlin/pl')
6 files changed, 16 insertions, 33 deletions
diff --git a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt index 62d22de9..323d0e1e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/form/Form.kt +++ b/src/main/kotlin/pl/treksoft/kvision/form/Form.kt @@ -23,6 +23,7 @@ package pl.treksoft.kvision.form import kotlinx.serialization.KSerializer import kotlinx.serialization.Mapper +import kotlinx.serialization.decode import kotlinx.serialization.json.JSON import kotlinx.serialization.serializer import pl.treksoft.kvision.form.upload.Upload @@ -44,27 +45,6 @@ internal data class FieldParams<in F : FormControl>( ) /** - * A wrapper for a Map with a custom containsKey method implementation. - * Used with kotlinx.serialization Mapper. - */ -private class FormMapWrapper<out V>(private val map: Map<String, V>) : Map<String, V> { - override fun equals(other: Any?): Boolean = map == other - override fun hashCode(): Int = map.hashCode() - override fun toString(): String = map.toString() - override val size: Int get() = map.size - override fun isEmpty(): Boolean = map.isEmpty() - override fun containsKey(key: String): Boolean = - if (key.indexOf('.') != -1) map.containsKey(key) else - !(map.containsKey("$key.time") || map.containsKey("$key.size")) - - override fun containsValue(value: @UnsafeVariance V): Boolean = map.containsValue(value) - override fun get(key: String): V? = map[key] - override val keys: Set<String> get() = map.keys - override val values: Collection<V> get() = map.values - override val entries: Set<Map.Entry<String, V>> get() = map.entries -} - -/** * The form definition class. Can be used directly or indirectly inside a [FormPanel]. * * @constructor Creates a form with a given modelFactory function @@ -94,9 +74,9 @@ class Form<K : Any>(private val panel: FormPanel<K>? = null, private val seriali listOf(entry.key to entry.value, "${entry.key}.size" to list.size) + list.mapIndexed { index, kFile -> listOf( - "${entry.key}.${index + 1}.name" to kFile.name, - "${entry.key}.${index + 1}.size" to kFile.size, - "${entry.key}.${index + 1}.content" to kFile.content + "${entry.key}.${index}.name" to kFile.name, + "${entry.key}.${index}.size" to kFile.size, + "${entry.key}.${index}.content" to kFile.content ) }.flatten() } ?: listOf() @@ -104,8 +84,8 @@ class Form<K : Any>(private val panel: FormPanel<K>? = null, private val seriali else -> listOf(entry.key to entry.value) } }.toMap() - val mapper = Mapper.InNullableMapper(FormMapWrapper(map)) - mapper.read(serializer) + val mapper = Mapper.InNullableMapper(map) + mapper.decode(serializer) } } diff --git a/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt b/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt index 0890d5a1..d5695db3 100644 --- a/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt +++ b/src/main/kotlin/pl/treksoft/kvision/modal/Dialog.kt @@ -21,8 +21,9 @@ */ package pl.treksoft.kvision.modal -import kotlinx.coroutines.experimental.suspendCancellableCoroutine +import kotlinx.coroutines.suspendCancellableCoroutine import pl.treksoft.kvision.core.Widget +import kotlin.coroutines.resume /** * Modal window with a result. diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt b/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt index c7103200..25c20445 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/RemoteAgent.kt @@ -21,8 +21,8 @@ */ package pl.treksoft.kvision.remote -import kotlinx.coroutines.experimental.Deferred -import kotlinx.coroutines.experimental.asDeferred +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.asDeferred import kotlinx.serialization.KSerializer import kotlinx.serialization.internal.ArrayListSerializer import kotlinx.serialization.internal.BooleanSerializer diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt b/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt index 2d4ab9eb..56141f5e 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/Security.kt @@ -21,8 +21,8 @@ */ package pl.treksoft.kvision.remote -import kotlinx.coroutines.experimental.Deferred -import kotlinx.coroutines.experimental.asDeferred +import kotlinx.coroutines.Deferred +import kotlinx.coroutines.asDeferred import kotlinx.serialization.Serializable import pl.treksoft.kvision.utils.obj diff --git a/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt b/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt index 0b2bba23..961bf176 100644 --- a/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt +++ b/src/main/kotlin/pl/treksoft/kvision/remote/ServiceManager.kt @@ -21,7 +21,7 @@ */ package pl.treksoft.kvision.remote -import kotlinx.coroutines.experimental.Deferred +import kotlinx.coroutines.Deferred /** * Multiplatform service manager. diff --git a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt index 203fac98..e5f608c2 100644 --- a/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt +++ b/src/main/kotlin/pl/treksoft/kvision/utils/Utils.kt @@ -24,13 +24,15 @@ package pl.treksoft.kvision.utils import com.lightningkite.kotlin.observable.list.ObservableList -import kotlinx.coroutines.experimental.suspendCancellableCoroutine +import kotlinx.coroutines.suspendCancellableCoroutine import org.w3c.files.File import org.w3c.files.FileReader import pl.treksoft.kvision.KVManager import pl.treksoft.kvision.core.CssSize import pl.treksoft.kvision.core.UNIT import kotlin.browser.window +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException import kotlin.js.Date /** |