From c139f85b99fba763ef28474d303d8b928e737420 Mon Sep 17 00:00:00 2001 From: Grishka Date: Wed, 9 Oct 2024 06:09:53 +0300 Subject: [PATCH] Fix wrong unread notification count for some accounts on 4.3 --- mastodon/build.gradle | 4 ++-- .../GetUnreadNotificationsCount.java | 19 ++++++++++++++++++- .../android/fragments/HomeFragment.java | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/mastodon/build.gradle b/mastodon/build.gradle index c24dc3e4..3757881b 100644 --- a/mastodon/build.gradle +++ b/mastodon/build.gradle @@ -13,8 +13,8 @@ android { applicationId "org.joinmastodon.android" minSdk 23 targetSdk 34 - versionCode 121 - versionName "2.7.2" + versionCode 122 + versionName "2.7.3" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } diff --git a/mastodon/src/main/java/org/joinmastodon/android/api/requests/notifications/GetUnreadNotificationsCount.java b/mastodon/src/main/java/org/joinmastodon/android/api/requests/notifications/GetUnreadNotificationsCount.java index e00f9654..d782fee2 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/api/requests/notifications/GetUnreadNotificationsCount.java +++ b/mastodon/src/main/java/org/joinmastodon/android/api/requests/notifications/GetUnreadNotificationsCount.java @@ -1,10 +1,27 @@ package org.joinmastodon.android.api.requests.notifications; +import org.joinmastodon.android.api.ApiUtils; import org.joinmastodon.android.api.MastodonAPIRequest; +import org.joinmastodon.android.model.NotificationType; + +import java.util.EnumSet; public class GetUnreadNotificationsCount extends MastodonAPIRequest{ - public GetUnreadNotificationsCount(){ + public GetUnreadNotificationsCount(EnumSet includeTypes, EnumSet groupedTypes){ super(HttpMethod.GET, "/notifications/unread_count", Response.class); + if(includeTypes!=null){ + for(String type: ApiUtils.enumSetToStrings(includeTypes, NotificationType.class)){ + addQueryParameter("types[]", type); + } + for(String type:ApiUtils.enumSetToStrings(EnumSet.complementOf(includeTypes), NotificationType.class)){ + addQueryParameter("exclude_types[]", type); + } + } + if(groupedTypes!=null){ + for(String type:ApiUtils.enumSetToStrings(groupedTypes, NotificationType.class)){ + addQueryParameter("grouped_types[]", type); + } + } } @Override diff --git a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java index fb2f18d1..59b2f998 100644 --- a/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java +++ b/mastodon/src/main/java/org/joinmastodon/android/fragments/HomeFragment.java @@ -296,7 +296,7 @@ public class HomeFragment extends AppKitFragment{ if(instance==null) return; if(instance.getApiVersion()>=2){ - new GetUnreadNotificationsCount() + new GetUnreadNotificationsCount(EnumSet.allOf(NotificationType.class), NotificationType.getGroupableTypes()) .setCallback(new Callback<>(){ @Override public void onSuccess(GetUnreadNotificationsCount.Response result){