Skip to content

Commit

Permalink
Add public select ScenarioID method
Browse files Browse the repository at this point in the history
  • Loading branch information
antranapp committed Feb 20, 2023
1 parent f81eb38 commit 27ebf80
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions Sources/Scenarios/BaseScenariosManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,11 @@ open class BaseScenariosManager {
}

@objc public func reset() {
activeScenarioId = nil
select(nil)
}

public func select(_ scenarioId: ScenarioId?) {
activeScenarioId = scenarioId
}

// MARK: Private helpers
Expand Down Expand Up @@ -163,15 +167,15 @@ open class BaseScenariosManager {
BaseScenarioSelectorAppController(
targetAudience: targetAudience
) { [weak self] id in
self?.activeScenarioId = id
self?.select(id)
}
}

@objc func refresh() {
let previousScenarioId = activeScenarioId

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self.activeScenarioId = previousScenarioId
self.select(previousScenarioId)
}
}

Expand Down
6 changes: 3 additions & 3 deletions Sources/Scenarios/ScenariosManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ open class ScenariosManager: BaseScenariosManager {
innerAppController = ScenarioSelectorSplitAppController(
targetAudience: targetAudience
) { [weak self] id in
self?.activeScenarioId = id
self?.select(id)
}
} else {
innerAppController = ScenarioSelectorAppController(
targetAudience: targetAudience,
favouriteScenarios: $favouriteScenarios.eraseToAnyPublisher(),
layout: scenarioListLayout
) { [weak self] id in
self?.activeScenarioId = id
self?.select(id)
}
}
} else {
Expand All @@ -81,7 +81,7 @@ open class ScenariosManager: BaseScenariosManager {
favouriteScenarios: $favouriteScenarios.eraseToAnyPublisher(),
layout: scenarioListLayout
) { [weak self] id in
self?.activeScenarioId = id
self?.select(id)
}
}

Expand Down

0 comments on commit 27ebf80

Please sign in to comment.