Skip to content

Commit

Permalink
MBX-3390 Fix settings operations
Browse files Browse the repository at this point in the history
  • Loading branch information
Akylbek Utekeshev committed Nov 25, 2024
1 parent 0ff2518 commit 2a2d512
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct PreparationContext {
var segments: [String] = []
var isNeedGeoRequest: Bool = false
var productSegments: [String] = []
var operationInapps: [String: [String]] = [:]
var operationInapps: [String: Set<String>] = [:]
}

protocol ITargetingChecker: AnyObject {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import Foundation
final class CategoryIDChecker: InternalTargetingChecker<CategoryIDTargeting> {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import Foundation
final class CategoryIDInChecker: InternalTargetingChecker<CategoryIDInTargeting> {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ final class CustomOperationChecker: InternalTargetingChecker<CustomOperationTarg
SessionTemporaryStorage.shared.observedCustomOperations.insert(operationName)

let key = targeting.systemName.lowercased()
context.operationInapps[key, default: []].append(id)
context.operationInapps[key, default: []].insert(id)
}

override func checkInternal(targeting: CustomOperationTargeting) -> Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ import Foundation
final class ProductIDChecker: InternalTargetingChecker<ProductIDTargeting> {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ final class ProductSegmentChecker: InternalTargetingChecker<ProductSegmentTarget
weak var checker: TargetingCheckerContextProtocol?

override func prepareInternal(id: String, targeting: ProductSegmentTargeting, context: inout PreparationContext) {
let key = "viewProduct".lowercased()
context.operationInapps[key, default: []].insert(id)
context.productSegments.append(targeting.segmentationExternalId)
}

Expand Down

0 comments on commit 2a2d512

Please sign in to comment.