From 2d11685b7b48c1e6e2e0cedc9239075dc2bb8aea Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Thu, 1 Aug 2024 17:41:02 +0600 Subject: [PATCH] fix using of json in new webapp types --- .../inmo/tgbotapi/webapps/stories/StoryShareParams.kt | 10 ++++++---- .../inmo/tgbotapi/webapps/stories/StoryWidgetLink.kt | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryShareParams.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryShareParams.kt index e3fb6f260e..c75e32660e 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryShareParams.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryShareParams.kt @@ -1,5 +1,7 @@ package dev.inmo.tgbotapi.webapps.stories +import kotlin.js.json + external interface StoryShareParams { val text: String @JsName("widget_link") @@ -10,8 +12,8 @@ fun StoryShareParams( text: String, widgetLink: StoryWidgetLink? ): StoryShareParams { - val result: dynamic = js("{}") - result["text"] = text - widgetLink ?.let { result["widget_link"] = it } - return result.unsafeCast() + val json = json() + json["text"] = text + widgetLink ?.let { json["widget_link"] = it } + return json.unsafeCast() } diff --git a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryWidgetLink.kt b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryWidgetLink.kt index 61ee95a034..b56959cbd6 100644 --- a/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryWidgetLink.kt +++ b/tgbotapi.webapps/src/jsMain/kotlin/dev/inmo/tgbotapi/webapps/stories/StoryWidgetLink.kt @@ -11,8 +11,8 @@ fun StoryWidgetLink( url: String, name: String? ): StoryWidgetLink { - val result: dynamic = js("{}") - result["url"] = url - name ?.let { result["name"] = it } - return result.unsafeCast() + val json = json() + json["url"] = url + name ?.let { json["name"] = it } + return json.unsafeCast() }