Skip to content

Commit

Permalink
Fix refreshing a scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
antranapp committed Nov 12, 2022
1 parent db353ec commit e3d36c1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions Sources/Scenarios/BaseScenariosManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,9 @@ open class BaseScenariosManager {
}

func setupBindings() {
let notificationCenter = NotificationCenter.default
notificationCenter.addObserver(self, selector: #selector(reset), name: .resetScenario, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(reset), name: .resetScenario, object: nil)
}

func updateContent() {
if let activeScenarioId = activeScenarioId {
if isInitialLaunch {
Expand All @@ -172,7 +171,7 @@ open class BaseScenariosManager {
let previsousScenarioId = activeScenarioId
activeScenarioId = nil

DispatchQueue.global().asyncAfter(deadline: .now() + 0.5) { [weak self] in
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { [weak self] in
DispatchQueue.main.async {
self?.activeScenarioId = previsousScenarioId
}
Expand All @@ -187,6 +186,10 @@ open class BaseScenariosManager {
scenarioListLayout = .nestedList
}
}

deinit {
NotificationCenter.default.removeObserver(self)
}
}

public protocol ScenarioPlugin {
Expand Down

0 comments on commit e3d36c1

Please sign in to comment.