Merge pull request #1832 from vector-im/feature/fix_timeline_loading
Fix timeline non loading when there are lots of filtered events
This commit is contained in:
commit
700a2e9ce3
|
@ -17,6 +17,7 @@ Bugfix 🐛:
|
|||
- Fix 404 on EMS (#1761)
|
||||
- Fix Infinite loop at startup when migrating account from Riot (#1699)
|
||||
- Fix Element crashes in loop after initial sync (#1709)
|
||||
- Fix timeline items not loading when there are only filtered events
|
||||
- Fix "Voice & Video" grayed out in Settings (#1733)
|
||||
- Fix Allow VOIP call in all rooms with 2 participants (even if not DM)
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ internal class DefaultTimeline(
|
|||
filteredEvents = nonFilteredEvents.where()
|
||||
.filterEventsWithSettings()
|
||||
.findAll()
|
||||
filteredEvents.addChangeListener(eventsChangeListener)
|
||||
nonFilteredEvents.addChangeListener(eventsChangeListener)
|
||||
handleInitialLoad()
|
||||
if (settings.shouldHandleHiddenReadReceipts()) {
|
||||
hiddenReadReceipts.start(realm, filteredEvents, nonFilteredEvents, this)
|
||||
|
|
|
@ -16,7 +16,9 @@
|
|||
|
||||
package im.vector.riotx.core.epoxy
|
||||
|
||||
import android.widget.ProgressBar
|
||||
import android.widget.TextView
|
||||
import androidx.core.view.isVisible
|
||||
import com.airbnb.epoxy.EpoxyAttribute
|
||||
import com.airbnb.epoxy.EpoxyModelClass
|
||||
import im.vector.riotx.R
|
||||
|
@ -26,14 +28,16 @@ import im.vector.riotx.core.extensions.setTextOrHide
|
|||
abstract class LoadingItem : VectorEpoxyModel<LoadingItem.Holder>() {
|
||||
|
||||
@EpoxyAttribute var loadingText: String? = null
|
||||
@EpoxyAttribute var showLoader: Boolean = true
|
||||
|
||||
override fun bind(holder: Holder) {
|
||||
super.bind(holder)
|
||||
|
||||
holder.progressBar.isVisible = showLoader
|
||||
holder.textView.setTextOrHide(loadingText)
|
||||
}
|
||||
|
||||
class Holder : VectorEpoxyHolder() {
|
||||
val textView by bind<TextView>(R.id.loadingText)
|
||||
val progressBar by bind<ProgressBar>(R.id.loadingProgress)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,7 +74,8 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
|||
fun onEncryptedMessageClicked(informationData: MessageInformationData, view: View)
|
||||
fun onImageMessageClicked(messageImageContent: MessageImageInfoContent, mediaData: ImageContentRenderer.Data, view: View)
|
||||
fun onVideoMessageClicked(messageVideoContent: MessageVideoContent, mediaData: VideoContentRenderer.Data, view: View)
|
||||
// fun onFileMessageClicked(eventId: String, messageFileContent: MessageFileContent)
|
||||
|
||||
// fun onFileMessageClicked(eventId: String, messageFileContent: MessageFileContent)
|
||||
// fun onAudioMessageClicked(messageAudioContent: MessageAudioContent)
|
||||
fun onEditedDecorationClicked(informationData: MessageInformationData)
|
||||
|
||||
|
@ -107,7 +108,6 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
|||
fun onUrlLongClicked(url: String): Boolean
|
||||
}
|
||||
|
||||
private var showingForwardLoader = false
|
||||
// Map eventId to adapter position
|
||||
private val adapterPositionMapping = HashMap<String, Int>()
|
||||
private val modelCache = arrayListOf<CacheItemData?>()
|
||||
|
@ -233,7 +233,8 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
|||
|
||||
override fun buildModels() {
|
||||
val timestamp = System.currentTimeMillis()
|
||||
showingForwardLoader = LoadingItem_()
|
||||
|
||||
val showingForwardLoader = LoadingItem_()
|
||||
.id("forward_loading_item_$timestamp")
|
||||
.setVisibilityStateChangedListener(Timeline.Direction.FORWARDS)
|
||||
.addWhenLoading(Timeline.Direction.FORWARDS)
|
||||
|
@ -242,13 +243,14 @@ class TimelineEventController @Inject constructor(private val dateFormatter: Vec
|
|||
add(timelineModels)
|
||||
|
||||
// Avoid displaying two loaders if there is no elements between them
|
||||
if (!showingForwardLoader || timelineModels.isNotEmpty()) {
|
||||
val showBackwardsLoader = !showingForwardLoader || timelineModels.isNotEmpty()
|
||||
// We can hide the loader but still add the item to controller so it can trigger backwards pagination
|
||||
LoadingItem_()
|
||||
.id("backward_loading_item_$timestamp")
|
||||
.setVisibilityStateChangedListener(Timeline.Direction.BACKWARDS)
|
||||
.showLoader(showBackwardsLoader)
|
||||
.addWhenLoading(Timeline.Direction.BACKWARDS)
|
||||
}
|
||||
}
|
||||
|
||||
// Timeline.LISTENER ***************************************************************************
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="1dp"
|
||||
android:background="?riotx_background"
|
||||
android:orientation="vertical">
|
||||
|
||||
|
|
Loading…
Reference in New Issue