~captainepoch/husky-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 2

[PATCH husky] Fix missing chats in app

Edward Sneed <sneeden@fedora.email>
Details
Message ID
<20220106011451.4363-1-sneeden@fedora.email>
DKIM signature
pass
Download raw message
Patch: +13 -13
---
This patch fixes the missing chats in its corresponding tab. It is copied from an unmaintained fork found at https://github.com/SamTherapy/Husky and was originally made by @sam@froth.zone (fediverse)
 .../tusky/network/MastodonApi.kt              |  2 +-
 .../tusky/repository/ChatRepository.kt        | 24 +++++++++----------
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/husky/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt b/husky/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt
index dda8201..b1a794a 100644
--- a/husky/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt
+++ b/husky/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt
@@ -631,7 +631,7 @@ interface MastodonApi {
            @Path("message_id") messageId: String
    ): Single<ChatMessage>

    @GET("api/v1/pleroma/chats")
    @GET("api/v2/pleroma/chats")
    fun getChats(
            @Query("max_id") maxId: String?,
            @Query("min_id") minId: String?,
diff --git a/husky/app/src/main/java/com/keylesspalace/tusky/repository/ChatRepository.kt b/husky/app/src/main/java/com/keylesspalace/tusky/repository/ChatRepository.kt
index d96df4c..6fa19c3 100644
--- a/husky/app/src/main/java/com/keylesspalace/tusky/repository/ChatRepository.kt
+++ b/husky/app/src/main/java/com/keylesspalace/tusky/repository/ChatRepository.kt
@@ -59,24 +59,24 @@ class ChatRepositoryImpl(
            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?,
                                       sinceIdMinusOne: String?, limit: Int,
                                       accountId: Long, requestMode: TimelineRequestMode
    ): Single<out List<ChatStatus>> {
        return mastodonApi.getChats(maxId, null, sinceIdMinusOne, 0, limit + 1)
                .map { chats ->
                    this.saveChatsToDb(accountId, chats, maxId, sinceId)
                }
                .flatMap { chats ->
                    this.addFromDbIfNeeded(accountId, chats, maxId, sinceId, limit, requestMode)
                }
                .onErrorResumeNext { error ->
                    if (error is IOException && requestMode != NETWORK) {
                        this.getChatsFromDb(accountId, maxId, sinceId, limit)
                    } else {
        return mastodonApi.getChats(null, null, sinceIdMinusOne, 0, limit + 1)
            .map { chats ->
                this.saveChatsToDb(accountId, chats, maxId, sinceId)
            }
            .flatMap { chats ->
                this.addFromDbIfNeeded(accountId, chats, maxId, sinceId, limit, requestMode)
            }
            .onErrorResumeNext { error ->
                if (error is IOException && requestMode != NETWORK) {
                    this.getChatsFromDb(accountId, maxId, sinceId, limit)
                } else {
                        Single.error(error)
                    }
                }
-- 
2.25.1
Details
Message ID
<CAKyg=SVv_LTmGFZGyOwgpYRRNrLMmkcs-RjfTcU6MojbQ33L9g@mail.gmail.com>
In-Reply-To
<20220106011451.4363-1-sneeden@fedora.email> (view parent)
DKIM signature
pass
Download raw message
"/api/v1/chats" doesn't exist anymore in Pleroma.
Also in v2 API supports pagination, so it can be also enabled in ChatFragment.

Looks fine to me, except formatting is off.

What do you think, captainepoch?

чт, 6 янв. 2022 г. в 04:15, Edward Sneed <sneeden@fedora.email>:
>
> ---
> This patch fixes the missing chats in its corresponding tab. It is copied from an unmaintained fork found at https://github.com/SamTherapy/Husky and was originally made by @sam@froth.zone (fediverse)
>  .../tusky/network/MastodonApi.kt              |  2 +-
>  .../tusky/repository/ChatRepository.kt        | 24 +++++++++----------
>  2 files changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/husky/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt b/husky/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt
> index dda8201..b1a794a 100644
> --- a/husky/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt
> +++ b/husky/app/src/main/java/com/keylesspalace/tusky/network/MastodonApi.kt
> @@ -631,7 +631,7 @@ interface MastodonApi {
>              @Path("message_id") messageId: String
>      ): Single<ChatMessage>
>
> -    @GET("api/v1/pleroma/chats")
> +    @GET("api/v2/pleroma/chats")
>      fun getChats(
>              @Query("max_id") maxId: String?,
>              @Query("min_id") minId: String?,
> diff --git a/husky/app/src/main/java/com/keylesspalace/tusky/repository/ChatRepository.kt b/husky/app/src/main/java/com/keylesspalace/tusky/repository/ChatRepository.kt
> index d96df4c..6fa19c3 100644
> --- a/husky/app/src/main/java/com/keylesspalace/tusky/repository/ChatRepository.kt
> +++ b/husky/app/src/main/java/com/keylesspalace/tusky/repository/ChatRepository.kt
> @@ -59,24 +59,24 @@ class ChatRepositoryImpl(
>              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?,
>                                         sinceIdMinusOne: String?, limit: Int,
>                                         accountId: Long, requestMode: TimelineRequestMode
>      ): Single<out List<ChatStatus>> {
> -        return mastodonApi.getChats(maxId, null, sinceIdMinusOne, 0, limit + 1)
> -                .map { chats ->
> -                    this.saveChatsToDb(accountId, chats, maxId, sinceId)
> -                }
> -                .flatMap { chats ->
> -                    this.addFromDbIfNeeded(accountId, chats, maxId, sinceId, limit, requestMode)
> -                }
> -                .onErrorResumeNext { error ->
> -                    if (error is IOException && requestMode != NETWORK) {
> -                        this.getChatsFromDb(accountId, maxId, sinceId, limit)
> -                    } else {
> +        return mastodonApi.getChats(null, null, sinceIdMinusOne, 0, limit + 1)
> +            .map { chats ->
> +                this.saveChatsToDb(accountId, chats, maxId, sinceId)
> +            }
> +            .flatMap { chats ->
> +                this.addFromDbIfNeeded(accountId, chats, maxId, sinceId, limit, requestMode)
> +            }
> +            .onErrorResumeNext { error ->
> +                if (error is IOException && requestMode != NETWORK) {
> +                    this.getChatsFromDb(accountId, maxId, sinceId, limit)
> +                } else {
>                          Single.error(error)
>                      }
>                  }
> --
> 2.25.1
>


-- 
1
Details
Message ID
<20220108061224.bus24ei5f3f6zgsf@MacBook-Pro-de-Adolfo.local>
In-Reply-To
<CAKyg=SVv_LTmGFZGyOwgpYRRNrLMmkcs-RjfTcU6MojbQ33L9g@mail.gmail.com> (view parent)
DKIM signature
pass
Download raw message
>"/api/v1/chats" doesn't exist anymore in Pleroma.
>Also in v2 API supports pagination, so it can be also enabled in ChatFragment.
>
>Looks fine to me, except formatting is off.
>
>What do you think, captainepoch?

If the v1 API does not exist anymore, I would delete it. Format is
alright, I'll format the patch while applying it.

I will setup a tool to format the code automatically soon, so the code
will be formatted equally for everyone.

I'll apply the patch as soon as I finish a WIP thing I'm doing right
now.

Cheers!
Details
Message ID
<20220116065731.ens7f36fg26ta7oh@MacBook-Pro-de-Adolfo.local>
In-Reply-To
<20220106011451.4363-1-sneeden@fedora.email> (view parent)
DKIM signature
pass
Download raw message
Patch applied, git commit 237241ba.

Thanks!
Reply to thread Export thread (mbox)