From 2a2d5125f513f89a0235c9703138923e9956fb7c Mon Sep 17 00:00:00 2001 From: Akylbek Utekeshev Date: Tue, 26 Nov 2024 04:36:37 +0500 Subject: [PATCH] MBX-3390 Fix settings operations --- .../InAppTargetingChecker/InternalTargetingChecker.swift | 2 +- .../TargetingCheckerTypes/CategoryIDChecker.swift | 5 ++++- .../TargetingCheckerTypes/CategoryIDInChecker.swift | 5 ++++- .../TargetingCheckerTypes/CustomOperationChecker.swift | 2 +- .../TargetingCheckerTypes/ProductIDChecker.swift | 5 ++++- .../TargetingCheckerTypes/ProductSegmentChecker.swift | 2 ++ 6 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Mindbox/InAppMessages/InAppTargetingChecker/InternalTargetingChecker.swift b/Mindbox/InAppMessages/InAppTargetingChecker/InternalTargetingChecker.swift index edcd4b58..944ef65d 100644 --- a/Mindbox/InAppMessages/InAppTargetingChecker/InternalTargetingChecker.swift +++ b/Mindbox/InAppMessages/InAppTargetingChecker/InternalTargetingChecker.swift @@ -12,7 +12,7 @@ struct PreparationContext { var segments: [String] = [] var isNeedGeoRequest: Bool = false var productSegments: [String] = [] - var operationInapps: [String: [String]] = [:] + var operationInapps: [String: Set] = [:] } protocol ITargetingChecker: AnyObject { diff --git a/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/CategoryIDChecker.swift b/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/CategoryIDChecker.swift index f51afed9..8e8fa6da 100644 --- a/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/CategoryIDChecker.swift +++ b/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/CategoryIDChecker.swift @@ -11,7 +11,10 @@ import Foundation final class CategoryIDChecker: InternalTargetingChecker { weak var checker: TargetingCheckerContextProtocol? - override func prepareInternal(id: String, targeting: CategoryIDTargeting, context: inout PreparationContext) {} + override func prepareInternal(id: String, targeting: CategoryIDTargeting, context: inout PreparationContext) { + let key = "viewCategory".lowercased() + context.operationInapps[key, default: []].insert(id) + } override func checkInternal(targeting: CategoryIDTargeting) -> Bool { guard let checker = checker, diff --git a/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/CategoryIDInChecker.swift b/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/CategoryIDInChecker.swift index 6516bbc4..6d014e4f 100644 --- a/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/CategoryIDInChecker.swift +++ b/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/CategoryIDInChecker.swift @@ -11,7 +11,10 @@ import Foundation final class CategoryIDInChecker: InternalTargetingChecker { weak var checker: TargetingCheckerContextProtocol? - override func prepareInternal(id: String, targeting: CategoryIDInTargeting, context: inout PreparationContext) {} + override func prepareInternal(id: String, targeting: CategoryIDInTargeting, context: inout PreparationContext) { + let key = "viewCategory".lowercased() + context.operationInapps[key, default: []].insert(id) + } override func checkInternal(targeting: CategoryIDInTargeting) -> Bool { guard let checker = checker, diff --git a/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/CustomOperationChecker.swift b/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/CustomOperationChecker.swift index e6a4ec14..3e7fd286 100644 --- a/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/CustomOperationChecker.swift +++ b/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/CustomOperationChecker.swift @@ -16,7 +16,7 @@ final class CustomOperationChecker: InternalTargetingChecker Bool { diff --git a/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/ProductIDChecker.swift b/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/ProductIDChecker.swift index fa4508f9..3597a148 100644 --- a/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/ProductIDChecker.swift +++ b/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/ProductIDChecker.swift @@ -11,7 +11,10 @@ import Foundation final class ProductIDChecker: InternalTargetingChecker { weak var checker: TargetingCheckerContextProtocol? - override func prepareInternal(id: String, targeting: ProductIDTargeting, context: inout PreparationContext) {} + override func prepareInternal(id: String, targeting: ProductIDTargeting, context: inout PreparationContext) { + let key = "viewProduct".lowercased() + context.operationInapps[key, default: []].insert(id) + } override func checkInternal(targeting: ProductIDTargeting) -> Bool { guard let checker = checker, diff --git a/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/ProductSegmentChecker.swift b/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/ProductSegmentChecker.swift index 0f83f6a6..795f5b0e 100644 --- a/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/ProductSegmentChecker.swift +++ b/Mindbox/InAppMessages/InAppTargetingChecker/TargetingCheckerTypes/ProductSegmentChecker.swift @@ -13,6 +13,8 @@ final class ProductSegmentChecker: InternalTargetingChecker