fix empty timeline on initial load (#2586)
This commit is contained in:
parent
2e33233309
commit
dba2fbc5c1
4 changed files with 10 additions and 4 deletions
|
@ -267,9 +267,12 @@ class CachedTimelineViewModel @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun 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()
|
currentPagingSource?.invalidate()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val MAX_STATUSES_IN_CACHE = 1000
|
private const val MAX_STATUSES_IN_CACHE = 1000
|
||||||
|
|
|
@ -249,7 +249,7 @@ class NetworkTimelineViewModel @Inject constructor(
|
||||||
currentSource?.invalidate()
|
currentSource?.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun invalidate() {
|
override suspend fun invalidate() {
|
||||||
currentSource?.invalidate()
|
currentSource?.invalidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ abstract class TimelineViewModel(
|
||||||
abstract fun fullReload()
|
abstract fun fullReload()
|
||||||
|
|
||||||
/** Triggered when currently displayed data must be reloaded. */
|
/** Triggered when currently displayed data must be reloaded. */
|
||||||
protected abstract fun invalidate()
|
protected abstract suspend fun invalidate()
|
||||||
|
|
||||||
protected fun shouldFilterStatus(statusViewData: StatusViewData): Boolean {
|
protected fun shouldFilterStatus(statusViewData: StatusViewData): Boolean {
|
||||||
val status = statusViewData.asStatusOrNull()?.status ?: return false
|
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")
|
@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?
|
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 a new issue