From 08a4d0be84c4f25c51f7f420b7d73bcd856e3f22 Mon Sep 17 00:00:00 2001 From: mueller-ma Date: Mon, 2 Dec 2024 19:42:54 +0100 Subject: [PATCH] Increase notification API page size Now notifications can be hidden by other notifications which might require that fetching 20 notifications isn't enough to fill one page. Thus increase the page size to 50. Also see #3837 --- .../java/org/openhab/habdroid/core/CloudMessagingHelper.kt | 3 ++- .../org/openhab/habdroid/ui/CloudNotificationListFragment.kt | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mobile/src/foss/java/org/openhab/habdroid/core/CloudMessagingHelper.kt b/mobile/src/foss/java/org/openhab/habdroid/core/CloudMessagingHelper.kt index 7046160232..32ee093088 100644 --- a/mobile/src/foss/java/org/openhab/habdroid/core/CloudMessagingHelper.kt +++ b/mobile/src/foss/java/org/openhab/habdroid/core/CloudMessagingHelper.kt @@ -26,6 +26,7 @@ import org.openhab.habdroid.core.connection.ConnectionFactory import org.openhab.habdroid.core.connection.NotACloudServerException import org.openhab.habdroid.model.CloudMessage import org.openhab.habdroid.model.toCloudMessage +import org.openhab.habdroid.ui.CloudNotificationListFragment import org.openhab.habdroid.ui.preference.PushNotificationStatus import org.openhab.habdroid.util.HttpClient import org.openhab.habdroid.util.PrefKeys @@ -65,7 +66,7 @@ object CloudMessagingHelper { } private suspend fun loadNewMessages(context: Context, connection: Connection): List? { - val url = "api/v1/notifications?limit=20" + val url = "api/v1/notifications?limit=${CloudNotificationListFragment.PAGE_SIZE}" val messages = try { val response = connection.httpClient.get(url).asText().response Log.d(TAG, "Notifications request success") diff --git a/mobile/src/main/java/org/openhab/habdroid/ui/CloudNotificationListFragment.kt b/mobile/src/main/java/org/openhab/habdroid/ui/CloudNotificationListFragment.kt index 4221f09229..070dc5f53a 100644 --- a/mobile/src/main/java/org/openhab/habdroid/ui/CloudNotificationListFragment.kt +++ b/mobile/src/main/java/org/openhab/habdroid/ui/CloudNotificationListFragment.kt @@ -210,9 +210,9 @@ class CloudNotificationListFragment : Fragment(), View.OnClickListener, SwipeRef } companion object { - private val TAG = CloudNotificationListFragment::class.java.simpleName + const val PAGE_SIZE = 50 - private const val PAGE_SIZE = 20 + private val TAG = CloudNotificationListFragment::class.java.simpleName fun newInstance(highlightedId: String?, primaryServer: Boolean): CloudNotificationListFragment { val f = CloudNotificationListFragment()