Skip to content

Commit

Permalink
WMSDK-411: Renaming some properties and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
justSmK committed Feb 14, 2025
1 parent 32d45a7 commit a20cfc5
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Mindbox/Extensions/Notification+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ import Foundation
extension Notification.Name {
static let initializationCompleted = Notification.Name("MBNotification-initializationCompleted")
static let shouldDiscardInapps = Notification.Name("MBNotification-shouldDiscardInapps")
static let inappConfigDownloaded = Notification.Name("MBNotification-inappConfigDownloaded")
static let mobileConfigDownloaded = Notification.Name("MBNotification-mobileConfigDownloaded")
}
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,16 @@ class InAppConfigurationManager: InAppConfigurationManagerProtocol {
SessionTemporaryStorage.shared.operationsFromSettings.insert(viewProduct.systemName.lowercased())
}

saveInappSessionToCache(config: settings.slidingExpiration?.config)
saveConfigSessionToCache(settings.slidingExpiration?.config)
}

private func createTTLValidationService() -> TTLValidationProtocol {
return TTLValidationService(persistenceStorage: self.persistenceStorage)
}

private func saveInappSessionToCache(config: String?) {
SessionTemporaryStorage.shared.expiredInappSession = config
Logger.common(message: "Saved slidingExpiration.config - \(config) to temporary storage.")
NotificationCenter.default.post(name: .inappConfigDownloaded, object: nil)
private func saveConfigSessionToCache(_ config: String?) {
SessionTemporaryStorage.shared.expiredConfigSession = config
Logger.common(message: "Saved slidingExpiration.config - \(String(describing: config)) to temporary storage.")
NotificationCenter.default.post(name: .mobileConfigDownloaded, object: nil)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ final class InappSessionManager: InappSessionManagerProtocol {
return
}

guard let sessionTimeInSeconds = getInappSession(), sessionTimeInSeconds > 0 else {
guard let sessionTimeInSeconds = getConfigSession(), sessionTimeInSeconds > 0 else {
Logger.common(message: "[InappSessionManager] expiredInappTime is nil/invalid or <= 0 — skip session expiration check.")
return
}
Expand Down Expand Up @@ -88,9 +88,9 @@ final class InappSessionManager: InappSessionManagerProtocol {
NotificationCenter.default.post(name: .shouldDiscardInapps, object: nil)
}

private func getInappSession() -> Double? {
guard let inappSession = SessionTemporaryStorage.shared.expiredInappSession,
let sessionTimeInSeconds = try? inappSession.parseTimeStampToSeconds() else {
private func getConfigSession() -> Double? {
guard let configSession = SessionTemporaryStorage.shared.expiredConfigSession,
let sessionTimeInSeconds = try? configSession.parseTimeStampToSeconds() else {
return nil
}

Expand All @@ -99,7 +99,7 @@ final class InappSessionManager: InappSessionManagerProtocol {

private func addObserverToDismissInApp() {
NotificationCenter.default.addObserver(
forName: .inappConfigDownloaded,
forName: .mobileConfigDownloaded,
object: nil,
queue: nil
) { [weak self] _ in
Expand All @@ -109,7 +109,7 @@ final class InappSessionManager: InappSessionManagerProtocol {

private func logNearestInappSessionExpirationTime() {
if let lastTrackVisitTimestamp = lastTrackVisitTimestamp,
let sessionTimeInSeconds = self.getInappSession(), sessionTimeInSeconds > 0 {
let sessionTimeInSeconds = self.getConfigSession(), sessionTimeInSeconds > 0 {
let expirationDate = lastTrackVisitTimestamp.addingTimeInterval(sessionTimeInSeconds)
Logger.common(message: "[InappSessionManager] Nearest session expiration time is \(expirationDate.asDateTimeWithSeconds).")
}
Expand Down
2 changes: 1 addition & 1 deletion Mindbox/Utilities/SessionTemporaryStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ final class SessionTemporaryStorage {
}
}

var expiredInappSession: String?
var expiredConfigSession: String?
var isUserVisitSaved = false
private init() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ final class InappSessionManagerTests: XCTestCase {
coreManagerMock = DI.injectOrFail(InAppCoreManagerProtocol.self) as? InAppCoreManagerMock
persistenceStorage = DI.injectOrFail(PersistenceStorage.self)
targetingChecker = DI.injectOrFail(InAppTargetingCheckerProtocol.self)
SessionTemporaryStorage.shared.expiredInappSession = ""
SessionTemporaryStorage.shared.expiredConfigSession = ""
}

override func tearDown() {
manager = nil
coreManagerMock = nil
SessionTemporaryStorage.shared.expiredInappSession = nil
SessionTemporaryStorage.shared.expiredConfigSession = nil
super.tearDown()
}

Expand All @@ -42,7 +42,7 @@ final class InappSessionManagerTests: XCTestCase {
manager.lastTrackVisitTimestamp = Date().addingTimeInterval(-100)
let oldTimestamp = manager.lastTrackVisitTimestamp

SessionTemporaryStorage.shared.expiredInappSession = nil
SessionTemporaryStorage.shared.expiredConfigSession = nil

manager.checkInappSession()

Expand All @@ -58,7 +58,7 @@ final class InappSessionManagerTests: XCTestCase {
manager.lastTrackVisitTimestamp = Date().addingTimeInterval(-100)
let oldTimestamp = manager.lastTrackVisitTimestamp

SessionTemporaryStorage.shared.expiredInappSession = "0.00:00:00.0000000"
SessionTemporaryStorage.shared.expiredConfigSession = "0.00:00:00.0000000"

manager.checkInappSession()

Expand All @@ -74,7 +74,7 @@ final class InappSessionManagerTests: XCTestCase {
manager.lastTrackVisitTimestamp = Date().addingTimeInterval(-100)
let oldTimestamp = manager.lastTrackVisitTimestamp

SessionTemporaryStorage.shared.expiredInappSession = "-0.00:00:01.0000000"
SessionTemporaryStorage.shared.expiredConfigSession = "-0.00:00:01.0000000"

manager.checkInappSession()

Expand All @@ -90,7 +90,7 @@ final class InappSessionManagerTests: XCTestCase {
manager.lastTrackVisitTimestamp = Date().addingTimeInterval(-100)
let oldTimestamp = manager.lastTrackVisitTimestamp

SessionTemporaryStorage.shared.expiredInappSession = "100"
SessionTemporaryStorage.shared.expiredConfigSession = "100"

manager.checkInappSession()

Expand All @@ -107,7 +107,7 @@ final class InappSessionManagerTests: XCTestCase {
manager.lastTrackVisitTimestamp = now.addingTimeInterval(-2400)
let oldTimestamp = manager.lastTrackVisitTimestamp

SessionTemporaryStorage.shared.expiredInappSession = "0.00:59:00.0000000"
SessionTemporaryStorage.shared.expiredConfigSession = "0.00:59:00.0000000"

manager.checkInappSession()

Expand All @@ -123,7 +123,7 @@ final class InappSessionManagerTests: XCTestCase {
manager.lastTrackVisitTimestamp = Date().addingTimeInterval(-2400)
let oldTimestamp = manager.lastTrackVisitTimestamp

SessionTemporaryStorage.shared.expiredInappSession = "0.00:30:00.0000000"
SessionTemporaryStorage.shared.expiredConfigSession = "0.00:30:00.0000000"

manager.checkInappSession()

Expand All @@ -140,7 +140,7 @@ final class InappSessionManagerTests: XCTestCase {
manager.lastTrackVisitTimestamp = now.addingTimeInterval(-2400)
let oldUserVisitCount = persistenceStorage.userVisitCount

SessionTemporaryStorage.shared.expiredInappSession = "0.00:59:00.0000000"
SessionTemporaryStorage.shared.expiredConfigSession = "0.00:59:00.0000000"

manager.checkInappSession()
XCTAssertEqual(persistenceStorage.userVisitCount, oldUserVisitCount)
Expand All @@ -151,7 +151,7 @@ final class InappSessionManagerTests: XCTestCase {

let oldUserVisitCount = persistenceStorage.userVisitCount

SessionTemporaryStorage.shared.expiredInappSession = "0.00:30:00.0000000"
SessionTemporaryStorage.shared.expiredConfigSession = "0.00:30:00.0000000"

manager.checkInappSession()
XCTAssertNotEqual(persistenceStorage.userVisitCount, oldUserVisitCount)
Expand All @@ -162,7 +162,7 @@ final class InappSessionManagerTests: XCTestCase {

func test_sessionUpdate_ResetStorages() {
manager.lastTrackVisitTimestamp = Date().addingTimeInterval(-2400)
SessionTemporaryStorage.shared.expiredInappSession = "0.00:30:00.0000000"
SessionTemporaryStorage.shared.expiredConfigSession = "0.00:30:00.0000000"

SessionTemporaryStorage.shared.observedCustomOperations = ["Test"]
SessionTemporaryStorage.shared.operationsFromSettings = ["Test2"]
Expand Down

0 comments on commit a20cfc5

Please sign in to comment.