Skip to content

Commit

Permalink
Merge branch 'rc/3.1.+' into rc/3.2.+
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	android/src/main/java/io/agora/rtc/react/PromiseCallback.kt
#	package.json
  • Loading branch information
LichKing-2234 committed Dec 28, 2020
2 parents 4b71f4d + 85c5823 commit ab02e67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
* upgrade to 3.2.0 ([4ee51a9](https://github.com/AgoraIO-Community/react-native-agora/commit/4ee51a9b405deb17b467f5359f6717033c3961a2))
* upgrade to 3.2.0 ([680048f](https://github.com/AgoraIO-Community/react-native-agora/commit/680048f7836940f586ce7228559ba2cde9e0de62))

## [3.1.7](https://github.com/AgoraIO-Community/react-native-agora/compare/v3.1.6...v3.1.7) (2020-12-28)


### Bug Fixes

* process resolve value type ([d28c79d](https://github.com/AgoraIO-Community/react-native-agora/commit/d28c79d18338604cbc6e723baedd9618e8a11374))

## [3.1.6](https://github.com/AgoraIO-Community/react-native-agora/compare/v3.1.5...v3.1.6) (2020-12-21)


Expand Down
21 changes: 13 additions & 8 deletions android/src/main/java/io/agora/rtc/react/PromiseCallback.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,21 @@ class PromiseCallback(
private val promise: Promise?
) : Callback() {
override fun success(data: Any?) {
if (data is Map<*, *>) {
val map = mutableMapOf<String, Any?>()
data.forEach {
if (it.key is String) {
map[it.key as String] = it.value
when (data) {
null, is Boolean, is Int, is String -> promise?.resolve(data)
is Number -> promise?.resolve(data.toDouble())
is Array<*> -> promise?.resolve(Arguments.makeNativeArray<Any>(arrayOf(data)))
is List<*> -> promise?.resolve(Arguments.makeNativeArray(data))
is Map<*, *> -> {
val map = mutableMapOf<String, Any?>()
data.forEach {
if (it.key is String) {
map[it.key as String] = it.value
}
}
promise?.resolve(Arguments.makeNativeMap(map))
}
promise?.resolve(Arguments.makeNativeMap(map))
} else {
promise?.resolve(data)
else -> promise?.reject(IllegalArgumentException("Could not convert " + data.javaClass))
}
}

Expand Down

0 comments on commit ab02e67

Please sign in to comment.