improved get messages task
This commit is contained in:
parent
d1b175b524
commit
d86dd71294
|
@ -137,16 +137,13 @@ class GetMessagesTask(
|
|||
val sincePagination = param.pagination?.get(accountsCount + index) as? SinceMaxPagination
|
||||
|
||||
val firstFetch by lazy {
|
||||
val firstFetchPref = preferences.getBoolean(KEY_FIRST_FETCH, true)
|
||||
val noConversationsBefore = DataStoreUtils.queryCount(context.contentResolver,
|
||||
Conversations.CONTENT_URI, Expression.equalsArgs(Conversations.ACCOUNT_KEY).sql,
|
||||
arrayOf(accountKey.toString())) <= 0
|
||||
return@lazy noConversationsBefore && firstFetchPref
|
||||
return@lazy noConversationsBefore
|
||||
}
|
||||
|
||||
val updateLastRead = param.pagination?.all {
|
||||
(it as? SinceMaxPagination)?.maxId != null
|
||||
} ?: false || firstFetch
|
||||
val updateLastRead = param.hasMaxIds || firstFetch
|
||||
|
||||
val received = microBlog.getDirectMessages(Paging().apply {
|
||||
count(100)
|
||||
|
@ -194,10 +191,6 @@ class GetMessagesTask(
|
|||
true, profileImageSize, updateLastRead)
|
||||
}
|
||||
|
||||
if (firstFetch) {
|
||||
preferences.edit().putBoolean(KEY_FIRST_FETCH, false).apply()
|
||||
}
|
||||
|
||||
return DatabaseUpdateData(conversations.values, insertMessages)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue