Skip to content

Commit

Permalink
style(android): apply ktlint 1.3.0 rullset
Browse files Browse the repository at this point in the history
  • Loading branch information
mym0404 committed Jul 2, 2024
1 parent 14f23b8 commit 71a136e
Show file tree
Hide file tree
Showing 31 changed files with 1,100 additions and 1,105 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,166 +18,165 @@ import net.mjstudio.rnkakao.core.util.putS
import net.mjstudio.rnkakao.core.util.rejectWith
import net.mjstudio.rnkakao.core.util.unix

class RNCKakaoChannelModule internal constructor(context: ReactApplicationContext) :
KakaoChannelSpec(context) {
override fun getName(): String {
return NAME
}
class RNCKakaoChannelModule internal constructor(
context: ReactApplicationContext,
) : KakaoChannelSpec(context) {
override fun getName(): String = NAME

@ReactMethod
override fun followChannel(
channelPublicId: String,
promise: Promise,
) = onMain {
val context =
currentActivity ?: run {
promise.rejectWith(ActivityNotFoundException())
return@onMain
}
@ReactMethod
override fun followChannel(
channelPublicId: String,
promise: Promise,
) = onMain {
val context =
currentActivity ?: run {
promise.rejectWith(ActivityNotFoundException())
return@onMain
}

TalkApiClient.instance.followChannel(context, channelPublicId) { followChannelResult, error ->
if (error != null) {
promise.rejectWith(error)
} else if (followChannelResult == null) {
promise.rejectWith(RNCKakaoResponseNotFoundException("followChannelResult"))
} else {
promise.resolve(followChannelResult.success)
}
TalkApiClient.instance.followChannel(context, channelPublicId) { followChannelResult, error ->
if (error != null) {
promise.rejectWith(error)
} else if (followChannelResult == null) {
promise.rejectWith(RNCKakaoResponseNotFoundException("followChannelResult"))
} else {
promise.resolve(followChannelResult.success)
}
}
}

@ReactMethod
override fun addChannel(
channelPublicId: String,
promise: Promise,
) = onMain {
val context =
currentActivity ?: run {
promise.rejectWith(ActivityNotFoundException())
return@onMain
}
@ReactMethod
override fun addChannel(
channelPublicId: String,
promise: Promise,
) = onMain {
val context =
currentActivity ?: run {
promise.rejectWith(ActivityNotFoundException())
return@onMain
}

TalkApiClient.instance.addChannel(context, channelPublicId) { error ->
if (error != null) {
promise.rejectWith(error)
} else {
promise.resolve(42)
}
TalkApiClient.instance.addChannel(context, channelPublicId) { error ->
if (error != null) {
promise.rejectWith(error)
} else {
promise.resolve(42)
}
}
}

@ReactMethod
override fun getAddChannelUrl(
channelPublicId: String,
promise: Promise,
) = onMain {
runCatching {
val url = TalkApiClient.instance.addChannelUrl(channelPublicId)
promise.resolve(url.toString())
}.onFailure {
promise.rejectWith(it)
}
@ReactMethod
override fun getAddChannelUrl(
channelPublicId: String,
promise: Promise,
) = onMain {
runCatching {
val url = TalkApiClient.instance.addChannelUrl(channelPublicId)
promise.resolve(url.toString())
}.onFailure {
promise.rejectWith(it)
}
}

@ReactMethod
override fun openAddChannelUrl(
channelPublicId: String,
promise: Promise,
) = onMain {
val context =
currentActivity ?: run {
promise.rejectWith(ActivityNotFoundException())
return@onMain
}
runCatching {
val url = TalkApiClient.instance.addChannelUrl(channelPublicId)
KakaoCustomTabsClient.openWithDefault(context, url)
promise.resolve(url.toString())
}.onFailure {
promise.rejectWith(it)
@ReactMethod
override fun openAddChannelUrl(
channelPublicId: String,
promise: Promise,
) = onMain {
val context =
currentActivity ?: run {
promise.rejectWith(ActivityNotFoundException())
return@onMain
}
runCatching {
val url = TalkApiClient.instance.addChannelUrl(channelPublicId)
KakaoCustomTabsClient.openWithDefault(context, url)
promise.resolve(url.toString())
}.onFailure {
promise.rejectWith(it)
}
}

@ReactMethod
override fun chatChannel(
channelPublicId: String,
promise: Promise,
) = onMain {
val context =
currentActivity ?: run {
promise.rejectWith(ActivityNotFoundException())
return@onMain
}
@ReactMethod
override fun chatChannel(
channelPublicId: String,
promise: Promise,
) = onMain {
val context =
currentActivity ?: run {
promise.rejectWith(ActivityNotFoundException())
return@onMain
}

TalkApiClient.instance.chatChannel(context, channelPublicId) { error ->
if (error != null) {
promise.rejectWith(error)
} else {
promise.resolve(42)
}
TalkApiClient.instance.chatChannel(context, channelPublicId) { error ->
if (error != null) {
promise.rejectWith(error)
} else {
promise.resolve(42)
}
}
}

@ReactMethod
override fun getChatChannelUrl(
channelPublicId: String,
promise: Promise,
) = onMain {
runCatching {
val url = TalkApiClient.instance.chatChannelUrl(channelPublicId)
promise.resolve(url.toString())
}.onFailure {
promise.rejectWith(it)
}
@ReactMethod
override fun getChatChannelUrl(
channelPublicId: String,
promise: Promise,
) = onMain {
runCatching {
val url = TalkApiClient.instance.chatChannelUrl(channelPublicId)
promise.resolve(url.toString())
}.onFailure {
promise.rejectWith(it)
}
}

@ReactMethod
override fun openChatChannelUrl(
channelPublicId: String,
promise: Promise,
) = onMain {
val context =
currentActivity ?: run {
promise.rejectWith(ActivityNotFoundException())
return@onMain
}
runCatching {
val url = TalkApiClient.instance.chatChannelUrl(channelPublicId)
KakaoCustomTabsClient.openWithDefault(context, url)
promise.resolve(url.toString())
}.onFailure {
promise.rejectWith(it)
@ReactMethod
override fun openChatChannelUrl(
channelPublicId: String,
promise: Promise,
) = onMain {
val context =
currentActivity ?: run {
promise.rejectWith(ActivityNotFoundException())
return@onMain
}
runCatching {
val url = TalkApiClient.instance.chatChannelUrl(channelPublicId)
KakaoCustomTabsClient.openWithDefault(context, url)
promise.resolve(url.toString())
}.onFailure {
promise.rejectWith(it)
}
}

@ReactMethod
override fun channels(
channelPublicIds: ReadableArray?,
promise: Promise,
) = onMain {
TalkApiClient.instance.channels(publicIds = channelPublicIds?.filterIsInstance<String>()) { relations, error ->
if (error != null) {
promise.rejectWith(error)
} else if (relations?.channels == null) {
promise.rejectWith(RNCKakaoResponseNotFoundException("channels"))
} else {
promise.resolve(
argArr().pushMapList(
relations.channels!!.map {
argMap().apply {
putS("uuid", it.uuid)
putS("encodedId", it.encodedId)
putS("relation", it.relation.name.lowercase())
putL("updateAt", it.updatedAt?.unix)
}
},
),
)
}
@ReactMethod
override fun channels(
channelPublicIds: ReadableArray?,
promise: Promise,
) = onMain {
TalkApiClient.instance.channels(publicIds = channelPublicIds?.filterIsInstance<String>()) { relations, error ->
if (error != null) {
promise.rejectWith(error)
} else if (relations?.channels == null) {
promise.rejectWith(RNCKakaoResponseNotFoundException("channels"))
} else {
promise.resolve(
argArr().pushMapList(
relations.channels!!.map {
argMap().apply {
putS("uuid", it.uuid)
putS("encodedId", it.encodedId)
putS("relation", it.relation.name.lowercase())
putL("updateAt", it.updatedAt?.unix)
}
},
),
)
}
}
}

companion object {
const val NAME = "RNCKakaoChannel"
}
companion object {
const val NAME = "RNCKakaoChannel"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@ class RNCKakaoChannelPackage : TurboReactPackage() {
override fun getModule(
name: String,
reactContext: ReactApplicationContext,
): NativeModule? {
return if (name == RNCKakaoChannelModule.NAME) {
): NativeModule? =
if (name == RNCKakaoChannelModule.NAME) {
RNCKakaoChannelModule(reactContext)
} else {
null
}
}

override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
return ReactModuleInfoProvider {
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider =
ReactModuleInfoProvider {
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
moduleInfos[RNCKakaoChannelModule.NAME] =
Expand All @@ -33,5 +32,4 @@ class RNCKakaoChannelPackage : TurboReactPackage() {
)
moduleInfos
}
}
}
5 changes: 3 additions & 2 deletions packages/channel/android/src/newarch/KakaoChannelSpec.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ package net.mjstudio.rnkakao.channel

import com.facebook.react.bridge.ReactApplicationContext

abstract class KakaoChannelSpec internal constructor(context: ReactApplicationContext) :
NativeKakaoChannelSpec(context)
abstract class KakaoChannelSpec internal constructor(
context: ReactApplicationContext,
) : NativeKakaoChannelSpec(context)
Loading

0 comments on commit 71a136e

Please sign in to comment.