From 3bd48514cfd26912a10fd2b80855520ff852219a Mon Sep 17 00:00:00 2001 From: Bernard Gatt Date: Tue, 7 Nov 2023 15:12:48 +0100 Subject: [PATCH 1/3] Adds priority property to message and sorts local store by priority. --- .../io/customer/messaginginapp/gist/data/listeners/Queue.kt | 4 +++- .../io/customer/messaginginapp/gist/data/model/Message.kt | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt index 6dcc9ad8f..2e821cc41 100644 --- a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt +++ b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt @@ -143,7 +143,9 @@ class Queue : GistListener { } private fun handleMessages(messages: List) { - for (message in messages) { + // Sorting messages by priority and placing nulls last. + val sortedMessages = messages.sortedWith(compareBy(nullsLast()) { it.priority }) + for (message in sortedMessages) { processMessage(message) } } diff --git a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/model/Message.kt b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/model/Message.kt index 9f3c1dda2..084074283 100644 --- a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/model/Message.kt +++ b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/model/Message.kt @@ -18,6 +18,7 @@ data class GistProperties( data class Message( val messageId: String = "", val instanceId: String = UUID.randomUUID().toString(), + val priority: Int? = null, val queueId: String? = null, val properties: Map? = null ) From 22f9b6463cff9428e9f9f8bf455ab07ab302ac73 Mon Sep 17 00:00:00 2001 From: Bernard Gatt Date: Wed, 8 Nov 2023 09:12:46 +0100 Subject: [PATCH 2/3] Removed unused variable --- .../java/io/customer/messaginginapp/gist/data/listeners/Queue.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt index 2e821cc41..3a76fb714 100644 --- a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt +++ b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt @@ -24,7 +24,6 @@ import retrofit2.converter.gson.GsonConverterFactory class Queue : GistListener { private var localMessageStore: MutableList = mutableListOf() - private val cacheMap = mutableMapOf() init { GistSdk.addListener(this) From d61728efa212e96f8c08428b1f792f85a9512c91 Mon Sep 17 00:00:00 2001 From: Bernard Gatt Date: Wed, 8 Nov 2023 11:02:39 +0100 Subject: [PATCH 3/3] Forcing a commit --- messaginginapp/api/messaginginapp.api | 14 ++++++++------ .../messaginginapp/gist/data/listeners/Queue.kt | 3 +-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/messaginginapp/api/messaginginapp.api b/messaginginapp/api/messaginginapp.api index 5f408c80c..0e5abe076 100644 --- a/messaginginapp/api/messaginginapp.api +++ b/messaginginapp/api/messaginginapp.api @@ -131,17 +131,19 @@ public final class io/customer/messaginginapp/gist/data/model/LogEvent { public final class io/customer/messaginginapp/gist/data/model/Message { public fun ()V - public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)V - public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V + public fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Ljava/util/Map;)V + public synthetic fun (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Ljava/util/Map;ILkotlin/jvm/internal/DefaultConstructorMarker;)V public final fun component1 ()Ljava/lang/String; public final fun component2 ()Ljava/lang/String; - public final fun component3 ()Ljava/lang/String; - public final fun component4 ()Ljava/util/Map; - public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;)Lio/customer/messaginginapp/gist/data/model/Message; - public static synthetic fun copy$default (Lio/customer/messaginginapp/gist/data/model/Message;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/util/Map;ILjava/lang/Object;)Lio/customer/messaginginapp/gist/data/model/Message; + public final fun component3 ()Ljava/lang/Integer; + public final fun component4 ()Ljava/lang/String; + public final fun component5 ()Ljava/util/Map; + public final fun copy (Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Ljava/util/Map;)Lio/customer/messaginginapp/gist/data/model/Message; + public static synthetic fun copy$default (Lio/customer/messaginginapp/gist/data/model/Message;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Integer;Ljava/lang/String;Ljava/util/Map;ILjava/lang/Object;)Lio/customer/messaginginapp/gist/data/model/Message; public fun equals (Ljava/lang/Object;)Z public final fun getInstanceId ()Ljava/lang/String; public final fun getMessageId ()Ljava/lang/String; + public final fun getPriority ()Ljava/lang/Integer; public final fun getProperties ()Ljava/util/Map; public final fun getQueueId ()Ljava/lang/String; public fun hashCode ()I diff --git a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt index 3a76fb714..b52ccc7b1 100644 --- a/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt +++ b/messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt @@ -16,7 +16,6 @@ import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.launch import okhttp3.Cache import okhttp3.OkHttpClient -import okhttp3.Response import okhttp3.ResponseBody.Companion.toResponseBody import retrofit2.Retrofit import retrofit2.converter.gson.GsonConverterFactory @@ -142,7 +141,7 @@ class Queue : GistListener { } private fun handleMessages(messages: List) { - // Sorting messages by priority and placing nulls last. + // Sorting messages by priority and placing nulls last val sortedMessages = messages.sortedWith(compareBy(nullsLast()) { it.priority }) for (message in sortedMessages) { processMessage(message)