Unverified Commit b405a032 authored by Rafael Kellermann Streit's avatar Rafael Kellermann Streit Committed by GitHub

Merge pull request #1931 from RocketChat/new/render-all-images-from-url

[NEW] Renders all images formats on the chat room from an url link.
parents b9c6f544 2c92fef1
......@@ -19,7 +19,6 @@ import chat.rocket.android.dagger.scope.PerFragment
import chat.rocket.android.db.DatabaseManager
import chat.rocket.android.emoji.EmojiParser
import chat.rocket.android.emoji.EmojiRepository
import chat.rocket.android.emoji.internal.isCustom
import chat.rocket.android.helper.MessageHelper
import chat.rocket.android.helper.MessageParser
import chat.rocket.android.helper.UserHelper
......@@ -32,7 +31,7 @@ import chat.rocket.android.server.domain.messageReadReceiptEnabled
import chat.rocket.android.server.domain.messageReadReceiptStoreUsers
import chat.rocket.android.server.domain.useRealName
import chat.rocket.android.server.infraestructure.ConnectionManagerFactory
import chat.rocket.android.util.extension.orFalse
import chat.rocket.android.util.extension.isImage
import chat.rocket.android.util.extensions.avatarUrl
import chat.rocket.android.util.extensions.ifNotNullNorEmpty
import chat.rocket.android.util.extensions.isNotNullNorEmpty
......@@ -127,7 +126,7 @@ class UiModelMapper @Inject constructor(
getChatRoomAsync(message.roomId)?.let { chatRoom ->
message.urls?.forEach { url ->
if (url.url.endsWith(".gif")) {
if (url.url.isImage()) {
val attachment = Attachment(imageUrl = url.url)
mapAttachment(message, attachment, chatRoom)?.let { list.add(it) }
} else {
......
package chat.rocket.android.util.extension
/**
* This purely checks if an url link ends with a image format.
*/
fun String.isImage() = endsWith(".gif") || endsWith(".png") || endsWith(".jpg") || endsWith("jpeg")
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment