Fix missing chats in app

Signed-off-by: Adolfo Santiago <epoch@nixnetmail.com>
This commit is contained in:
Edward Sneed 2022-01-05 19:14:51 -06:00 committed by Adolfo Santiago
parent 9bc7e522a6
commit 237241baa1
No known key found for this signature in database
GPG key ID: 244D6F9A317B4A65
2 changed files with 13 additions and 13 deletions

View file

@ -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?,

View file

@ -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)
} }
} }