mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 20:06:51 +03:00
Merge pull request #2561 from SpiritCroc/url_preview_visibility
Properly hide preview URLs for messages that don't support previews
This commit is contained in:
commit
5744939c05
2 changed files with 13 additions and 3 deletions
|
@ -8,7 +8,7 @@ Improvements 🙌:
|
|||
-
|
||||
|
||||
Bugfix 🐛:
|
||||
-
|
||||
- Url previews sometimes attached to wrong message (#2561)
|
||||
|
||||
Translations 🗣:
|
||||
-
|
||||
|
|
|
@ -19,6 +19,7 @@ package im.vector.app.features.home.room.detail.timeline.item
|
|||
import android.text.method.MovementMethod
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.core.text.PrecomputedTextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.core.widget.TextViewCompat
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
|
@ -60,7 +61,12 @@ abstract class MessageTextItem : AbsMessageItem<MessageTextItem.Holder>() {
|
|||
// Preview URL
|
||||
previewUrlViewUpdater.previewUrlView = holder.previewUrlView
|
||||
previewUrlViewUpdater.imageContentRenderer = imageContentRenderer
|
||||
previewUrlRetriever?.addListener(attributes.informationData.eventId, previewUrlViewUpdater)
|
||||
val safePreviewUrlRetriever = previewUrlRetriever
|
||||
if (safePreviewUrlRetriever == null) {
|
||||
holder.previewUrlView.isVisible = false
|
||||
} else {
|
||||
safePreviewUrlRetriever.addListener(attributes.informationData.eventId, previewUrlViewUpdater)
|
||||
}
|
||||
holder.previewUrlView.delegate = previewUrlCallback
|
||||
|
||||
if (useBigFont) {
|
||||
|
@ -106,7 +112,11 @@ abstract class MessageTextItem : AbsMessageItem<MessageTextItem.Holder>() {
|
|||
var imageContentRenderer: ImageContentRenderer? = null
|
||||
|
||||
override fun onStateUpdated(state: PreviewUrlUiState) {
|
||||
val safeImageContentRenderer = imageContentRenderer ?: return
|
||||
val safeImageContentRenderer = imageContentRenderer
|
||||
if (safeImageContentRenderer == null) {
|
||||
previewUrlView?.isVisible = false
|
||||
return
|
||||
}
|
||||
previewUrlView?.render(state, safeImageContentRenderer)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue