fix empty timeline on initial load (#2586)
This commit is contained in:
parent
2e33233309
commit
dba2fbc5c1
|
@ -267,8 +267,11 @@ class CachedTimelineViewModel @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
override fun invalidate() {
|
||||
currentPagingSource?.invalidate()
|
||||
override suspend fun invalidate() {
|
||||
// invalidating when we don't have statuses yet can cause empty timelines because it cancels the network load
|
||||
if (db.timelineDao().getStatusCount(accountManager.activeAccount!!.id) > 0) {
|
||||
currentPagingSource?.invalidate()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -249,7 +249,7 @@ class NetworkTimelineViewModel @Inject constructor(
|
|||
currentSource?.invalidate()
|
||||
}
|
||||
|
||||
override fun invalidate() {
|
||||
override suspend fun invalidate() {
|
||||
currentSource?.invalidate()
|
||||
}
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ abstract class TimelineViewModel(
|
|||
abstract fun fullReload()
|
||||
|
||||
/** Triggered when currently displayed data must be reloaded. */
|
||||
protected abstract fun invalidate()
|
||||
protected abstract suspend fun invalidate()
|
||||
|
||||
protected fun shouldFilterStatus(statusViewData: StatusViewData): Boolean {
|
||||
val status = statusViewData.asStatusOrNull()?.status ?: return false
|
||||
|
|
|
@ -197,4 +197,7 @@ AND timelineUserId = :accountId
|
|||
*/
|
||||
@Query("SELECT serverId FROM TimelineStatusEntity WHERE timelineUserId = :accountId AND authorServerId IS NULL AND (LENGTH(:serverId) > LENGTH(serverId) OR (LENGTH(:serverId) = LENGTH(serverId) AND :serverId > serverId)) ORDER BY LENGTH(serverId) DESC, serverId DESC LIMIT 1")
|
||||
abstract suspend fun getNextPlaceholderIdAfter(accountId: Long, serverId: String): String?
|
||||
|
||||
@Query("SELECT COUNT(*) FROM TimelineStatusEntity WHERE timelineUserId = :accountId")
|
||||
abstract suspend fun getStatusCount(accountId: Long): Int
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue