Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.21.1 #45

Merged
merged 1 commit into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Changelog
### v3.21.1 (Nov 12, 2024) with Chat SDK `v4.20.0`
* Fixed thumbs up reaction not working in chat messages.
### v3.21.0 (Sep 12, 2024) with Chat SDK `v4.19.0`
* Changed the Form type message UI rendering due to the modification of the Form model from BaseMessage to MessageForm.
* Sendbird Business Messaging changes
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ android.nonTransitiveRClass=false
android.nonFinalResIds=false
android.enableR8.fullMode=false

UIKIT_VERSION = 3.21.0
UIKIT_VERSION = 3.21.1
UIKIT_VERSION_CODE = 1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ enum class Region {
NO1,
NO2,
NO3,
NO4
NO4,
NO5
;
}
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ internal fun Region.apiHost(): String? {
Region.NO2 -> "https://api-no2.sendbirdtest.com"
Region.NO3 -> "https://api-no3.sendbirdtest.com"
Region.NO4 -> "https://api-no4.sendbirdtest.com"
Region.NO5 -> "https://api-no5.sendbirdtest.com"
else -> null
}
}
Expand All @@ -203,6 +204,7 @@ internal fun Region.wsHost(): String? {
Region.NO2 -> "wss://ws-no2.sendbirdtest.com"
Region.NO3 -> "wss://ws-no3.sendbirdtest.com"
Region.NO4 -> "wss://ws-no4.sendbirdtest.com"
Region.NO5 -> "wss://ws-no5.sendbirdtest.com"
else -> null
}
}
1 change: 1 addition & 0 deletions uikit-samples/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,6 @@
<item>NO2</item>
<item>NO3</item>
<item>NO4</item>
<item>NO5</item>
</string-array>
</resources>
4 changes: 2 additions & 2 deletions uikit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

// Sendbird
api 'com.sendbird.sdk:sendbird-chat:4.19.0'
api 'com.sendbird.sdk:sendbird-chat:4.20.0'

implementation 'com.github.bumptech.glide:glide:4.16.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.16.0'
Expand All @@ -96,7 +96,7 @@ dokkaHtml {

String dokkaBaseConfiguration = """
{
"footerMessage": "<a href=\\"https://dashboard.sendbird.com/settings/contact_us\\">Report a bug or request a feature.</a>\\tFor further developer documentation, see <a href=\\"https://sendbird.com/docs/uikit/v3/android/overview\\">UIkit SDK Documentation</a>. That documentation contains more detailed descriptions, conceptual overviews, definitions of terms, and code examples.<br/> Copyright &copy; 2022, Sendbird or its affiliates. All rights reserved."
"footerMessage": "<a href=\\"https://dashboard.sendbird.com/settings/contact_us\\">Report a bug or request a feature.</a>\\tFor further developer documentation, see <a href=\\"https://sendbird.com/docs/chat/uikit/v3/android-view/overview\\">UIkit SDK Documentation</a>. That documentation contains more detailed descriptions, conceptual overviews, definitions of terms, and code examples.<br/> Copyright &copy; 2022, Sendbird or its affiliates. All rights reserved."
}
"""
pluginsMapConfiguration.set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.sendbird.android.message.Emoji
import com.sendbird.android.message.Reaction

internal fun Collection<Emoji>.containsEmoji(emojiKey: String): Boolean {
if (emojiKey == "sendbird_emoji_thumbsup") return false
return this.any { it.key == emojiKey }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import com.sendbird.uikit.internal.singleton.JsonParser
import com.sendbird.uikit.log.Logger
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject

@Serializable
internal data class NotificationTemplateList constructor(
Expand All @@ -14,7 +16,17 @@ internal data class NotificationTemplateList constructor(
companion object {
@JvmStatic
fun fromJson(value: String): NotificationTemplateList {
return JsonParser.fromJson(value)
val mutableTemplates = mutableListOf<NotificationTemplate>()
JsonParser.toJsonElement(value).jsonObject[KeySet.templates]?.jsonArray?.let { templateList ->
for (element in templateList) {
try {
mutableTemplates.add(JsonParser.fromJsonElement(element))
} catch (e: Exception) {
e.printStackTrace()
}
}
}
return NotificationTemplateList(mutableTemplates.toList())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ internal object KeySet {
const val sub_data = "sub_data"
const val sub_type = "sub_type"
const val carouselView = "carouselView"
const val templates = "templates"

// notifications
const val key = "key"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import kotlinx.serialization.decodeFromString
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.encodeToJsonElement
import kotlinx.serialization.json.decodeFromJsonElement

internal object JsonParser {
private val json by lazy {
Expand All @@ -24,7 +24,12 @@ internal object JsonParser {
}

@JvmStatic
inline fun <reified T> toJsonElement(value: T): JsonElement {
return json.encodeToJsonElement(value)
inline fun <reified T> fromJsonElement(element: JsonElement): T {
return json.decodeFromJsonElement(element)
}

@JvmStatic
internal fun toJsonElement(value: String): JsonElement {
return json.parseToJsonElement(value)
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.sendbird.uikit.internal.singleton

import android.content.Context
import androidx.annotation.VisibleForTesting
import androidx.annotation.WorkerThread
import com.sendbird.android.exception.SendbirdException
import com.sendbird.uikit.internal.extensions.runOnUiThread
Expand All @@ -13,6 +14,8 @@ import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.Executors
import java.util.concurrent.atomic.AtomicBoolean

@VisibleForTesting
internal const val MAX_REQUEST_TEMPLATE_RETRY_COUNT = 10
internal object NotificationChannelManager {
private data class TemplateRequestData(
val key: String,
Expand All @@ -24,9 +27,13 @@ internal object NotificationChannelManager {
private val worker = Executors.newFixedThreadPool(10)
private val isInitialized: AtomicBoolean = AtomicBoolean()
private val templateRequestDatas: MutableMap<String, MutableSet<TemplateRequestData>> = ConcurrentHashMap()
@VisibleForTesting
internal val templateRequestCount: MutableMap<String, Int> = ConcurrentHashMap()

private lateinit var templateRepository: NotificationTemplateRepository
private lateinit var channelSettingsRepository: NotificationChannelRepository
@VisibleForTesting
internal lateinit var templateRepository: NotificationTemplateRepository
@VisibleForTesting
internal lateinit var channelSettingsRepository: NotificationChannelRepository

/**
* To avoid sending an unintended exception, if the NotificationChannelManager hasn't been initialized it tries to initialize automatically.
Expand Down Expand Up @@ -71,6 +78,14 @@ internal object NotificationChannelManager {
return
}

// Apply a retry count to prevent infinite requests in case of failure.
val retryCount = templateRequestCount[key] ?: 0
if (retryCount >= MAX_REQUEST_TEMPLATE_RETRY_COUNT) {
notifyError(key, SendbirdException("Too many template requests have been made.[key=$key]"))
return
}
templateRequestCount[key] = retryCount + 1

synchronized(templateRequestDatas) {
val request = TemplateRequestData(key, variables, themeMode, callback)
templateRequestDatas[key]?.let {
Expand All @@ -89,6 +104,7 @@ internal object NotificationChannelManager {
val rawTemplate = templateRepository.requestTemplateBlocking(key)
makeAndNotifyTemplate(key, rawTemplate)
} catch (e: Throwable) {
templateRequestCount[key] = 1
notifyError(key, SendbirdException(e))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ internal class NotificationTemplateRepository(context: Context) {
) { notificationTemplateList, _, token, e ->
error = e
try {
if (!token.isNullOrEmpty()) lastCacheToken = token
val templateList = notificationTemplateList?.let {
NotificationTemplateList.fromJson(it.jsonPayload)
}
if (!token.isNullOrEmpty()) lastCacheToken = token
result.set(templateList)
} catch (e: Throwable) {
error = SendbirdException("notification template list data is not valid", e)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
android:paddingTop="@dimen/sb_size_8"
android:paddingEnd="@dimen/sb_size_16"
android:paddingBottom="@dimen/sb_size_8"
xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

Expand All @@ -27,6 +28,7 @@
android:layout_marginStart="@dimen/sb_size_10"
android:maxLines="1"
android:ellipsize="end"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@+id/ivProfile"
app:layout_constraintEnd_toStartOf="@+id/tvDescription"
Expand All @@ -35,7 +37,7 @@

<TextView
android:id="@+id/tvDescription"
android:layout_width="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/sb_size_6"
android:maxLines="1"
Expand Down