From 71c497e1f2781788c52e7a1ad93bcfca777e5efb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Kalici=C5=84ski?= Date: Wed, 31 Jul 2024 23:05:11 +0200 Subject: [PATCH] ktlint --- build.gradle.kts | 3 --- pubnub-chat-api/build.gradle.kts | 3 --- .../kotlin/com/pubnub/chat/types/Types.kt | 18 ++++++++++----- pubnub-chat-impl/build.gradle.kts | 4 ---- .../com/pubnub/chat/internal/ChatImpl.kt | 22 +++++++++++++++---- .../chat/internal/message/BaseMessage.kt | 4 +++- 6 files changed, 34 insertions(+), 20 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 19f8562d..d088d20b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,4 @@ import com.pubnub.gradle.tasks.GenerateVersionTask -import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType -import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport -import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn plugins { kotlin("multiplatform") version "2.0.0" diff --git a/pubnub-chat-api/build.gradle.kts b/pubnub-chat-api/build.gradle.kts index bab8f33d..db7b73ee 100644 --- a/pubnub-chat-api/build.gradle.kts +++ b/pubnub-chat-api/build.gradle.kts @@ -1,6 +1,3 @@ -import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport -import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn - plugins { kotlin("multiplatform") version "2.0.0" kotlin("plugin.serialization") version "2.0.0" diff --git a/pubnub-chat-api/src/commonMain/kotlin/com/pubnub/chat/types/Types.kt b/pubnub-chat-api/src/commonMain/kotlin/com/pubnub/chat/types/Types.kt index 073704a4..f82859e1 100644 --- a/pubnub-chat-api/src/commonMain/kotlin/com/pubnub/chat/types/Types.kt +++ b/pubnub-chat-api/src/commonMain/kotlin/com/pubnub/chat/types/Types.kt @@ -63,11 +63,19 @@ sealed class EventContent { val files: List? = null, ) : EventContent() { override fun equals(other: Any?): Boolean { - if (this === other) return true - if (other !is TextMessageContent) return false - - if (text != other.text) return false - if (files != other.files) return false + if (this === other) { + return true + } + if (other !is TextMessageContent) { + return false + } + + if (text != other.text) { + return false + } + if (files != other.files) { + return false + } return true } diff --git a/pubnub-chat-impl/build.gradle.kts b/pubnub-chat-impl/build.gradle.kts index 71cf9a14..4e29a2ed 100644 --- a/pubnub-chat-impl/build.gradle.kts +++ b/pubnub-chat-impl/build.gradle.kts @@ -1,7 +1,3 @@ -import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType -import org.jetbrains.kotlin.gradle.targets.js.yarn.YarnLockMismatchReport -import org.jetbrains.kotlin.gradle.targets.js.yarn.yarn - plugins { kotlin("multiplatform") version "2.0.0" kotlin("plugin.serialization") version "2.0.0" diff --git a/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/ChatImpl.kt b/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/ChatImpl.kt index 9d34f42c..8a649f14 100644 --- a/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/ChatImpl.kt +++ b/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/ChatImpl.kt @@ -574,7 +574,9 @@ class ChatImpl( callback: (event: Event) -> Unit ): AutoCloseable { val handler = fun(_: PubNub, pnEvent: PNEvent) { - if (pnEvent.channel != channelId) return + if (pnEvent.channel != channelId) { + return + } val message = (pnEvent as? MessageResult)?.message ?: return val eventContent: EventContent = PNDataEncoder.decode(message) @@ -593,8 +595,16 @@ class ChatImpl( val method = type.getEmitMethod() ?: customMethod val listener = createEventListener( pubNub, - onMessage = if (method == EmitEventMethod.PUBLISH) handler else { _, _ -> }, - onSignal = if (method == EmitEventMethod.SIGNAL) handler else { _, _ -> }, + onMessage = if (method == EmitEventMethod.PUBLISH) { + handler + } else { + { _, _ -> } + }, + onSignal = if (method == EmitEventMethod.SIGNAL) { + handler + } else { + { _, _ -> } + }, ) val channelEntity = pubNub.channel(channelId) val subscription = channelEntity.subscription() @@ -637,7 +647,11 @@ class ChatImpl( channelId = userId, payload = EventContent.Moderation( channelId = channel, - restriction = if (restriction.ban) RestrictionType.BAN else RestrictionType.MUTE, + restriction = if (restriction.ban) { + RestrictionType.BAN + } else { + RestrictionType.MUTE + }, reason = restriction.reason ), ) diff --git a/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/message/BaseMessage.kt b/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/message/BaseMessage.kt index 2a3750ed..cd613bb8 100644 --- a/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/message/BaseMessage.kt +++ b/pubnub-chat-impl/src/commonMain/kotlin/com/pubnub/chat/internal/message/BaseMessage.kt @@ -236,7 +236,9 @@ abstract class BaseMessage( val listener = createEventListener(chat.pubNub, onMessageAction = { _, event -> val message = latestMessages.find { it.timetoken == event.messageAction.messageTimetoken } ?: return@createEventListener - if (message.channelId != event.channel) return@createEventListener + if (message.channelId != event.channel) { + return@createEventListener + } val actions = if (event.event == "added") { assignAction( message.actions,