Skip to content

Commit

Permalink
refactor: use single line function
Browse files Browse the repository at this point in the history
  • Loading branch information
krocard committed Dec 6, 2023
1 parent d272236 commit e035a36
Showing 1 changed file with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,23 @@ class PlayerModule(context: ReactApplicationContext) : BitmovinBaseModule(contex
playerConfigJson: ReadableMap?,
analyticsConfigJson: ReadableMap?,
promise: Promise,
) {
promise.unit.resolveOnUiThread {
if (players.containsKey(nativeId)) {
throw IllegalArgumentException("Duplicate player creation for id $nativeId")
}
val playerConfig = playerConfigJson?.toPlayerConfig() ?: PlayerConfig()
val analyticsConfig = analyticsConfigJson?.toAnalyticsConfig()
val defaultMetadata = analyticsConfigJson?.getMap("defaultMetadata")?.toAnalyticsDefaultMetadata()

players[nativeId] = if (analyticsConfig == null) {
Player.create(context, playerConfig)
} else {
Player.create(
context = context,
playerConfig = playerConfig,
analyticsConfig = analyticsConfig,
defaultMetadata = defaultMetadata ?: DefaultMetadata(),
)
}
) = promise.unit.resolveOnUiThread {
if (players.containsKey(nativeId)) {
throw IllegalArgumentException("Duplicate player creation for id $nativeId")
}
val playerConfig = playerConfigJson?.toPlayerConfig() ?: PlayerConfig()
val analyticsConfig = analyticsConfigJson?.toAnalyticsConfig()
val defaultMetadata = analyticsConfigJson?.getMap("defaultMetadata")?.toAnalyticsDefaultMetadata()

players[nativeId] = if (analyticsConfig == null) {
Player.create(context, playerConfig)
} else {
Player.create(
context = context,
playerConfig = playerConfig,
analyticsConfig = analyticsConfig,
defaultMetadata = defaultMetadata ?: DefaultMetadata(),
)
}
}

Expand Down

0 comments on commit e035a36

Please sign in to comment.