Fix missing chats in app
Signed-off-by: Adolfo Santiago <epoch@nixnetmail.com>
This commit is contained in:
parent
9bc7e522a6
commit
237241baa1
2 changed files with 13 additions and 13 deletions
|
@ -631,7 +631,7 @@ interface MastodonApi {
|
||||||
@Path("message_id") messageId: String
|
@Path("message_id") messageId: String
|
||||||
): Single<ChatMessage>
|
): Single<ChatMessage>
|
||||||
|
|
||||||
@GET("api/v1/pleroma/chats")
|
@GET("api/v2/pleroma/chats")
|
||||||
fun getChats(
|
fun getChats(
|
||||||
@Query("max_id") maxId: String?,
|
@Query("max_id") maxId: String?,
|
||||||
@Query("min_id") minId: String?,
|
@Query("min_id") minId: String?,
|
||||||
|
|
|
@ -59,24 +59,24 @@ class ChatRepositoryImpl(
|
||||||
getChatMessagesFromNetwork(chatId, maxId, sinceId, sincedIdMinusOne, limit, accountId, requestMode)
|
getChatMessagesFromNetwork(chatId, maxId, sinceId, sincedIdMinusOne, limit, accountId, requestMode)
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
return getChatMessagesFromNetwork(chatId, maxId, sinceId, sincedIdMinusOne, limit, accountId, requestMode)
|
return getChatMessagesFromNetwork(chatId, maxId, null, null, limit, accountId, requestMode)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getChatsFromNetwork(maxId: String?, sinceId: String?,
|
private fun getChatsFromNetwork(maxId: String?, sinceId: String?,
|
||||||
sinceIdMinusOne: String?, limit: Int,
|
sinceIdMinusOne: String?, limit: Int,
|
||||||
accountId: Long, requestMode: TimelineRequestMode
|
accountId: Long, requestMode: TimelineRequestMode
|
||||||
): Single<out List<ChatStatus>> {
|
): Single<out List<ChatStatus>> {
|
||||||
return mastodonApi.getChats(maxId, null, sinceIdMinusOne, 0, limit + 1)
|
return mastodonApi.getChats(null, null, sinceIdMinusOne, 0, limit + 1)
|
||||||
.map { chats ->
|
.map { chats ->
|
||||||
this.saveChatsToDb(accountId, chats, maxId, sinceId)
|
this.saveChatsToDb(accountId, chats, maxId, sinceId)
|
||||||
}
|
}
|
||||||
.flatMap { chats ->
|
.flatMap { chats ->
|
||||||
this.addFromDbIfNeeded(accountId, chats, maxId, sinceId, limit, requestMode)
|
this.addFromDbIfNeeded(accountId, chats, maxId, sinceId, limit, requestMode)
|
||||||
}
|
}
|
||||||
.onErrorResumeNext { error ->
|
.onErrorResumeNext { error ->
|
||||||
if (error is IOException && requestMode != NETWORK) {
|
if (error is IOException && requestMode != NETWORK) {
|
||||||
this.getChatsFromDb(accountId, maxId, sinceId, limit)
|
this.getChatsFromDb(accountId, maxId, sinceId, limit)
|
||||||
} else {
|
} else {
|
||||||
Single.error(error)
|
Single.error(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue