Skip to content

Commit b5cf24d

Browse files
committed
chore: handle isContentEmpty for ClearMessageQueue
1 parent a6911dd commit b5cf24d

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

.github/workflows/snapshot-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,4 @@ jobs:
155155
gradle-version: ${{ matrix.gradle-version }}
156156

157157
- name: Building ${{ matrix.sample-app }} with AGP version ${{ matrix.agp-version }}
158-
run: ./gradlew ":samples:${{ matrix.sample-app }}:assembleRelease" --refresh-dependencies
158+
run: ./gradlew ":samples:${{ matrix.sample-app }}:assembleRelease"

messaginginapp/src/main/java/io/customer/messaginginapp/gist/data/listeners/Queue.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ internal class Queue : GistQueue {
160160

161161
private fun handleNoContent(responseCode: Int) {
162162
logger.debug("No messages found for user with response code: $responseCode")
163-
inAppMessagingManager.dispatch(InAppMessagingAction.ClearMessageQueue)
163+
inAppMessagingManager.dispatch(InAppMessagingAction.ClearMessageQueue(isContentEmpty = true))
164164
}
165165

166166
// For cached responses (304), apply locally cached opened status to preserve user's changes.
@@ -217,7 +217,7 @@ internal class Queue : GistQueue {
217217

218218
private fun handleFailedFetch(responseCode: Int) {
219219
logger.error("Failed to fetch messages: $responseCode")
220-
inAppMessagingManager.dispatch(InAppMessagingAction.ClearMessageQueue)
220+
inAppMessagingManager.dispatch(InAppMessagingAction.ClearMessageQueue(isContentEmpty = false))
221221
}
222222

223223
private fun updatePollingInterval(headers: Headers) {

messaginginapp/src/main/java/io/customer/messaginginapp/state/InAppMessageReducer.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ internal val inAppMessagingReducer: Reducer<InAppMessagingState> = { state, acti
2424
state.copy(anonymousId = action.anonymousId)
2525

2626
is InAppMessagingAction.ClearMessageQueue ->
27-
state.copy(messagesInQueue = emptySet())
27+
if (action.isContentEmpty) {
28+
state.copy(messagesInQueue = emptySet(), inboxMessages = emptySet())
29+
} else {
30+
// Only clear the message queue, keep inbox messages until explicitly cleared to show cached content if needed
31+
state.copy(messagesInQueue = emptySet())
32+
}
2833

2934
is InAppMessagingAction.ProcessMessageQueue ->
3035
state.copy(messagesInQueue = action.messages.toSet())
@@ -54,6 +59,9 @@ internal val inAppMessagingReducer: Reducer<InAppMessagingState> = { state, acti
5459
state.copy(inboxMessages = updatedMessages)
5560
}
5661

62+
is InAppMessagingAction.InboxAction.TrackClicked ->
63+
state // No state changes for tap action
64+
5765
is InAppMessagingAction.SetPollingInterval ->
5866
state.copy(pollInterval = action.interval)
5967

messaginginapp/src/main/java/io/customer/messaginginapp/state/InAppMessagingAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ internal sealed class InAppMessagingAction {
3131
data class TrackClicked(override val message: InboxMessage, val actionName: String?) : InboxAction(message)
3232
}
3333

34-
object ClearMessageQueue : InAppMessagingAction()
34+
data class ClearMessageQueue(val isContentEmpty: Boolean) : InAppMessagingAction()
3535
object Reset : InAppMessagingAction()
3636
}
3737

0 commit comments

Comments
 (0)