@react-native-kakao/channel 2.2.3 → 2.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,166 +18,165 @@ import net.mjstudio.rnkakao.core.util.putS
18
18
  import net.mjstudio.rnkakao.core.util.rejectWith
19
19
  import net.mjstudio.rnkakao.core.util.unix
20
20
 
21
- class RNCKakaoChannelModule internal constructor(context: ReactApplicationContext) :
22
- KakaoChannelSpec(context) {
23
- override fun getName(): String {
24
- return NAME
25
- }
21
+ class RNCKakaoChannelModule internal constructor(
22
+ context: ReactApplicationContext,
23
+ ) : KakaoChannelSpec(context) {
24
+ override fun getName(): String = NAME
26
25
 
27
- @ReactMethod
28
- override fun followChannel(
29
- channelPublicId: String,
30
- promise: Promise,
31
- ) = onMain {
32
- val context =
33
- currentActivity ?: run {
34
- promise.rejectWith(ActivityNotFoundException())
35
- return@onMain
36
- }
26
+ @ReactMethod
27
+ override fun followChannel(
28
+ channelPublicId: String,
29
+ promise: Promise,
30
+ ) = onMain {
31
+ val context =
32
+ currentActivity ?: run {
33
+ promise.rejectWith(ActivityNotFoundException())
34
+ return@onMain
35
+ }
37
36
 
38
- TalkApiClient.instance.followChannel(context, channelPublicId) { followChannelResult, error ->
39
- if (error != null) {
40
- promise.rejectWith(error)
41
- } else if (followChannelResult == null) {
42
- promise.rejectWith(RNCKakaoResponseNotFoundException("followChannelResult"))
43
- } else {
44
- promise.resolve(followChannelResult.success)
45
- }
37
+ TalkApiClient.instance.followChannel(context, channelPublicId) { followChannelResult, error ->
38
+ if (error != null) {
39
+ promise.rejectWith(error)
40
+ } else if (followChannelResult == null) {
41
+ promise.rejectWith(RNCKakaoResponseNotFoundException("followChannelResult"))
42
+ } else {
43
+ promise.resolve(followChannelResult.success)
46
44
  }
47
45
  }
46
+ }
48
47
 
49
- @ReactMethod
50
- override fun addChannel(
51
- channelPublicId: String,
52
- promise: Promise,
53
- ) = onMain {
54
- val context =
55
- currentActivity ?: run {
56
- promise.rejectWith(ActivityNotFoundException())
57
- return@onMain
58
- }
48
+ @ReactMethod
49
+ override fun addChannel(
50
+ channelPublicId: String,
51
+ promise: Promise,
52
+ ) = onMain {
53
+ val context =
54
+ currentActivity ?: run {
55
+ promise.rejectWith(ActivityNotFoundException())
56
+ return@onMain
57
+ }
59
58
 
60
- TalkApiClient.instance.addChannel(context, channelPublicId) { error ->
61
- if (error != null) {
62
- promise.rejectWith(error)
63
- } else {
64
- promise.resolve(42)
65
- }
59
+ TalkApiClient.instance.addChannel(context, channelPublicId) { error ->
60
+ if (error != null) {
61
+ promise.rejectWith(error)
62
+ } else {
63
+ promise.resolve(42)
66
64
  }
67
65
  }
66
+ }
68
67
 
69
- @ReactMethod
70
- override fun getAddChannelUrl(
71
- channelPublicId: String,
72
- promise: Promise,
73
- ) = onMain {
74
- runCatching {
75
- val url = TalkApiClient.instance.addChannelUrl(channelPublicId)
76
- promise.resolve(url.toString())
77
- }.onFailure {
78
- promise.rejectWith(it)
79
- }
68
+ @ReactMethod
69
+ override fun getAddChannelUrl(
70
+ channelPublicId: String,
71
+ promise: Promise,
72
+ ) = onMain {
73
+ runCatching {
74
+ val url = TalkApiClient.instance.addChannelUrl(channelPublicId)
75
+ promise.resolve(url.toString())
76
+ }.onFailure {
77
+ promise.rejectWith(it)
80
78
  }
79
+ }
81
80
 
82
- @ReactMethod
83
- override fun openAddChannelUrl(
84
- channelPublicId: String,
85
- promise: Promise,
86
- ) = onMain {
87
- val context =
88
- currentActivity ?: run {
89
- promise.rejectWith(ActivityNotFoundException())
90
- return@onMain
91
- }
92
- runCatching {
93
- val url = TalkApiClient.instance.addChannelUrl(channelPublicId)
94
- KakaoCustomTabsClient.openWithDefault(context, url)
95
- promise.resolve(url.toString())
96
- }.onFailure {
97
- promise.rejectWith(it)
81
+ @ReactMethod
82
+ override fun openAddChannelUrl(
83
+ channelPublicId: String,
84
+ promise: Promise,
85
+ ) = onMain {
86
+ val context =
87
+ currentActivity ?: run {
88
+ promise.rejectWith(ActivityNotFoundException())
89
+ return@onMain
98
90
  }
91
+ runCatching {
92
+ val url = TalkApiClient.instance.addChannelUrl(channelPublicId)
93
+ KakaoCustomTabsClient.openWithDefault(context, url)
94
+ promise.resolve(url.toString())
95
+ }.onFailure {
96
+ promise.rejectWith(it)
99
97
  }
98
+ }
100
99
 
101
- @ReactMethod
102
- override fun chatChannel(
103
- channelPublicId: String,
104
- promise: Promise,
105
- ) = onMain {
106
- val context =
107
- currentActivity ?: run {
108
- promise.rejectWith(ActivityNotFoundException())
109
- return@onMain
110
- }
100
+ @ReactMethod
101
+ override fun chatChannel(
102
+ channelPublicId: String,
103
+ promise: Promise,
104
+ ) = onMain {
105
+ val context =
106
+ currentActivity ?: run {
107
+ promise.rejectWith(ActivityNotFoundException())
108
+ return@onMain
109
+ }
111
110
 
112
- TalkApiClient.instance.chatChannel(context, channelPublicId) { error ->
113
- if (error != null) {
114
- promise.rejectWith(error)
115
- } else {
116
- promise.resolve(42)
117
- }
111
+ TalkApiClient.instance.chatChannel(context, channelPublicId) { error ->
112
+ if (error != null) {
113
+ promise.rejectWith(error)
114
+ } else {
115
+ promise.resolve(42)
118
116
  }
119
117
  }
118
+ }
120
119
 
121
- @ReactMethod
122
- override fun getChatChannelUrl(
123
- channelPublicId: String,
124
- promise: Promise,
125
- ) = onMain {
126
- runCatching {
127
- val url = TalkApiClient.instance.chatChannelUrl(channelPublicId)
128
- promise.resolve(url.toString())
129
- }.onFailure {
130
- promise.rejectWith(it)
131
- }
120
+ @ReactMethod
121
+ override fun getChatChannelUrl(
122
+ channelPublicId: String,
123
+ promise: Promise,
124
+ ) = onMain {
125
+ runCatching {
126
+ val url = TalkApiClient.instance.chatChannelUrl(channelPublicId)
127
+ promise.resolve(url.toString())
128
+ }.onFailure {
129
+ promise.rejectWith(it)
132
130
  }
131
+ }
133
132
 
134
- @ReactMethod
135
- override fun openChatChannelUrl(
136
- channelPublicId: String,
137
- promise: Promise,
138
- ) = onMain {
139
- val context =
140
- currentActivity ?: run {
141
- promise.rejectWith(ActivityNotFoundException())
142
- return@onMain
143
- }
144
- runCatching {
145
- val url = TalkApiClient.instance.chatChannelUrl(channelPublicId)
146
- KakaoCustomTabsClient.openWithDefault(context, url)
147
- promise.resolve(url.toString())
148
- }.onFailure {
149
- promise.rejectWith(it)
133
+ @ReactMethod
134
+ override fun openChatChannelUrl(
135
+ channelPublicId: String,
136
+ promise: Promise,
137
+ ) = onMain {
138
+ val context =
139
+ currentActivity ?: run {
140
+ promise.rejectWith(ActivityNotFoundException())
141
+ return@onMain
150
142
  }
143
+ runCatching {
144
+ val url = TalkApiClient.instance.chatChannelUrl(channelPublicId)
145
+ KakaoCustomTabsClient.openWithDefault(context, url)
146
+ promise.resolve(url.toString())
147
+ }.onFailure {
148
+ promise.rejectWith(it)
151
149
  }
150
+ }
152
151
 
153
- @ReactMethod
154
- override fun channels(
155
- channelPublicIds: ReadableArray?,
156
- promise: Promise,
157
- ) = onMain {
158
- TalkApiClient.instance.channels(publicIds = channelPublicIds?.filterIsInstance<String>()) { relations, error ->
159
- if (error != null) {
160
- promise.rejectWith(error)
161
- } else if (relations?.channels == null) {
162
- promise.rejectWith(RNCKakaoResponseNotFoundException("channels"))
163
- } else {
164
- promise.resolve(
165
- argArr().pushMapList(
166
- relations.channels!!.map {
167
- argMap().apply {
168
- putS("uuid", it.uuid)
169
- putS("encodedId", it.encodedId)
170
- putS("relation", it.relation.name.lowercase())
171
- putL("updateAt", it.updatedAt?.unix)
172
- }
173
- },
174
- ),
175
- )
176
- }
152
+ @ReactMethod
153
+ override fun channels(
154
+ channelPublicIds: ReadableArray?,
155
+ promise: Promise,
156
+ ) = onMain {
157
+ TalkApiClient.instance.channels(publicIds = channelPublicIds?.filterIsInstance<String>()) { relations, error ->
158
+ if (error != null) {
159
+ promise.rejectWith(error)
160
+ } else if (relations?.channels == null) {
161
+ promise.rejectWith(RNCKakaoResponseNotFoundException("channels"))
162
+ } else {
163
+ promise.resolve(
164
+ argArr().pushMapList(
165
+ relations.channels!!.map {
166
+ argMap().apply {
167
+ putS("uuid", it.uuid)
168
+ putS("encodedId", it.encodedId)
169
+ putS("relation", it.relation.name.lowercase())
170
+ putL("updateAt", it.updatedAt?.unix)
171
+ }
172
+ },
173
+ ),
174
+ )
177
175
  }
178
176
  }
177
+ }
179
178
 
180
- companion object {
181
- const val NAME = "RNCKakaoChannel"
182
- }
179
+ companion object {
180
+ const val NAME = "RNCKakaoChannel"
183
181
  }
182
+ }
@@ -10,16 +10,15 @@ class RNCKakaoChannelPackage : TurboReactPackage() {
10
10
  override fun getModule(
11
11
  name: String,
12
12
  reactContext: ReactApplicationContext,
13
- ): NativeModule? {
14
- return if (name == RNCKakaoChannelModule.NAME) {
13
+ ): NativeModule? =
14
+ if (name == RNCKakaoChannelModule.NAME) {
15
15
  RNCKakaoChannelModule(reactContext)
16
16
  } else {
17
17
  null
18
18
  }
19
- }
20
19
 
21
- override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
22
- return ReactModuleInfoProvider {
20
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider =
21
+ ReactModuleInfoProvider {
23
22
  val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
24
23
  val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
25
24
  moduleInfos[RNCKakaoChannelModule.NAME] =
@@ -33,5 +32,4 @@ class RNCKakaoChannelPackage : TurboReactPackage() {
33
32
  )
34
33
  moduleInfos
35
34
  }
36
- }
37
35
  }
@@ -2,5 +2,6 @@ package net.mjstudio.rnkakao.channel
2
2
 
3
3
  import com.facebook.react.bridge.ReactApplicationContext
4
4
 
5
- abstract class KakaoChannelSpec internal constructor(context: ReactApplicationContext) :
6
- NativeKakaoChannelSpec(context)
5
+ abstract class KakaoChannelSpec internal constructor(
6
+ context: ReactApplicationContext,
7
+ ) : NativeKakaoChannelSpec(context)
@@ -5,45 +5,46 @@ import com.facebook.react.bridge.ReactApplicationContext
5
5
  import com.facebook.react.bridge.ReactContextBaseJavaModule
6
6
  import com.facebook.react.bridge.ReadableArray
7
7
 
8
- abstract class KakaoChannelSpec internal constructor(context: ReactApplicationContext) :
9
- ReactContextBaseJavaModule(context) {
10
- abstract fun followChannel(
11
- channelPublicId: String,
12
- promise: Promise,
13
- )
14
-
15
- abstract fun addChannel(
16
- channelPublicId: String,
17
- promise: Promise,
18
- )
19
-
20
- abstract fun getAddChannelUrl(
21
- channelPublicId: String,
22
- promise: Promise,
23
- )
24
-
25
- abstract fun openAddChannelUrl(
26
- channelPublicId: String,
27
- promise: Promise,
28
- )
29
-
30
- abstract fun chatChannel(
31
- channelPublicId: String,
32
- promise: Promise,
33
- )
34
-
35
- abstract fun getChatChannelUrl(
36
- channelPublicId: String,
37
- promise: Promise,
38
- )
39
-
40
- abstract fun openChatChannelUrl(
41
- channelPublicId: String,
42
- promise: Promise,
43
- )
44
-
45
- abstract fun channels(
46
- channelPublicIds: ReadableArray?,
47
- promise: Promise,
48
- )
49
- }
8
+ abstract class KakaoChannelSpec internal constructor(
9
+ context: ReactApplicationContext,
10
+ ) : ReactContextBaseJavaModule(context) {
11
+ abstract fun followChannel(
12
+ channelPublicId: String,
13
+ promise: Promise,
14
+ )
15
+
16
+ abstract fun addChannel(
17
+ channelPublicId: String,
18
+ promise: Promise,
19
+ )
20
+
21
+ abstract fun getAddChannelUrl(
22
+ channelPublicId: String,
23
+ promise: Promise,
24
+ )
25
+
26
+ abstract fun openAddChannelUrl(
27
+ channelPublicId: String,
28
+ promise: Promise,
29
+ )
30
+
31
+ abstract fun chatChannel(
32
+ channelPublicId: String,
33
+ promise: Promise,
34
+ )
35
+
36
+ abstract fun getChatChannelUrl(
37
+ channelPublicId: String,
38
+ promise: Promise,
39
+ )
40
+
41
+ abstract fun openChatChannelUrl(
42
+ channelPublicId: String,
43
+ promise: Promise,
44
+ )
45
+
46
+ abstract fun channels(
47
+ channelPublicIds: ReadableArray?,
48
+ promise: Promise,
49
+ )
50
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@react-native-kakao/channel",
3
3
  "description": "React Native Kakao Channel SDK",
4
- "version": "2.2.3",
4
+ "version": "2.2.5",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
7
  "types": "lib/typescript/src/index.d.ts",
@@ -62,7 +62,7 @@
62
62
  "access": "public"
63
63
  },
64
64
  "devDependencies": {
65
- "@react-native-kakao/core": "2.2.3",
65
+ "@react-native-kakao/core": "2.2.5",
66
66
  "@types/invariant": "^2",
67
67
  "@types/jest": "^29.5.5",
68
68
  "@types/react": "^18.2.44",
@@ -74,7 +74,7 @@
74
74
  "typescript": "5.1.6"
75
75
  },
76
76
  "peerDependencies": {
77
- "@react-native-kakao/core": "2.2.3",
77
+ "@react-native-kakao/core": "2.2.5",
78
78
  "react": "*",
79
79
  "react-native": "*"
80
80
  },
@@ -113,5 +113,5 @@
113
113
  "dependencies": {
114
114
  "@mj-studio/js-util": "^1.0.34"
115
115
  },
116
- "gitHead": "2ed9d6e300920b7056a8f539ab11a2592e0064a2"
116
+ "gitHead": "0ecf72a2948e71f464fbc27f7369f13b77916cbd"
117
117
  }