Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
sumeruchat committed Jan 8, 2025
1 parent b8af9b1 commit a3ab1e7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
6 changes: 3 additions & 3 deletions swift-sdk/Internal/in-app/InAppManager+Functions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Foundation

enum MessagesProcessorResult {
case show(message: IterableInAppMessage, messagesMap: OrderedDictionary<String, IterableInAppMessage>)
case noShow(messagesMap: OrderedDictionary<String, IterableInAppMessage>)
case noShow(message: IterableInAppMessage?, messagesMap: OrderedDictionary<String, IterableInAppMessage>)
}

struct MessagesProcessor {
Expand All @@ -32,9 +32,9 @@ struct MessagesProcessor {
return processMessages()
case let .skipAndConsume(message):
updateMessage(message, didProcessTrigger: true, consumed: true)
return processMessages()
return .noShow(message: message, messagesMap: messagesMap)
case .none, .wait:
return .noShow(messagesMap: messagesMap)
return .noShow(message: nil, messagesMap: messagesMap)
}
}

Expand Down
11 changes: 9 additions & 2 deletions swift-sdk/Internal/in-app/InAppManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {

private func getMessagesMap(fromMessagesProcessorResult messagesProcessorResult: MessagesProcessorResult) -> OrderedDictionary<String, IterableInAppMessage> {
switch messagesProcessorResult {
case let .noShow(messagesMap: messagesMap):
case let .noShow(message: _, messagesMap: messagesMap):
return messagesMap
case .show(message: _, messagesMap: let messagesMap):
return messagesMap
Expand All @@ -300,14 +300,21 @@ class InAppManager: NSObject, IterableInternalInAppManagerProtocol {
ITBDebug("Setting last display time: \(String(describing: lastDisplayTime))")

show(message: message, consume: !message.saveToInbox)
}
}
}

private func processAndShowMessage(messagesMap: OrderedDictionary<String, IterableInAppMessage>) {
var processor = MessagesProcessor(inAppDelegate: inAppDelegate, inAppDisplayChecker: self, messagesMap: messagesMap)
let messagesProcessorResult = processor.processMessages()
self.messagesMap = getMessagesMap(fromMessagesProcessorResult: messagesProcessorResult)

if case let .noShow(message, _) = messagesProcessorResult,
let message = message, message.isJsonOnly {
requestHandler?.inAppConsume(message.messageId,
onSuccess: nil,
onFailure: nil)
}

showMessage(fromMessagesProcessorResult: messagesProcessorResult)
}

Expand Down

0 comments on commit a3ab1e7

Please sign in to comment.