Skip to content

Commit

Permalink
Merge pull request #300 from boostcampwm2023/iOS/task/Map-RewindScene…
Browse files Browse the repository at this point in the history
…Bugfix

[iOS] Map, Rewind Scene BugFix
  • Loading branch information
SwiftyJunnos authored Dec 11, 2023
2 parents 44d9fd8 + c82d580 commit f503e88
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public final class MapViewController: UIViewController {
viewModel.state.visibleJourneys
.receive(on: DispatchQueue.main)
.sink { [weak self] journeys in
self?.clearAnnotations()
self?.addAnnotations(with: journeys)
self?.drawPolyLinesToMap(with: journeys)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public final class MSProgressView: UIProgressView {
// MARK: - Functions: change progress

private func syncProgress(percentage: Float) {
self.progress = percentage
DispatchQueue.main.async { self.progress = percentage }
}

// MARK: - Timer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ final class MSProgressViewModel {
// MARK: - Functions: Timers

internal func startTimer() {
self.timer = Timer.publish(every: self.timerTimeInterval, on: .main, in: .common)
self.timer = Timer.publish(every: self.timerTimeInterval, on: .current, in: .common)
.autoconnect()
.receive(on: DispatchQueue.global(qos: .background))
.sink { [weak self] _ in
guard let remainingTime = self?.remainingTime,
let timerDuration = self?.timerDuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ public final class RewindJourneyViewController: UIViewController {

private var cancellables: Set<AnyCancellable> = []
private var presentingImageIndex: Int? {
didSet { self.changeProgressViews() }
didSet {
DispatchQueue.main.async { self.changeProgressViews() }
self.restartTimer()
}
}

// MARK: - Properties: Timer
Expand Down Expand Up @@ -87,9 +90,9 @@ public final class RewindJourneyViewController: UIViewController {

public override func viewDidLoad() {
super.viewDidLoad()
self.progressViewBinding()
self.timerBinding()
self.configure()
self.bind()
self.viewModel.trigger(.viewNeedsLoaded)
}

Expand All @@ -103,7 +106,7 @@ public final class RewindJourneyViewController: UIViewController {

// MARK: - Combine Binding

private func bind() {
private func progressViewBinding() {
self.viewModel.state.photoURLs
.sink { [weak self] urls in
self?.configureProgressViewsLayout(urls: urls)
Expand All @@ -122,8 +125,8 @@ public final class RewindJourneyViewController: UIViewController {
}

private func restartTimer() {
self.viewModel.trigger(.startAutoPlay)
self.viewModel.trigger(.stopAutoPlay)
self.viewModel.trigger(.startAutoPlay)
}

// MARK: - Configuration
Expand Down Expand Up @@ -183,6 +186,7 @@ public final class RewindJourneyViewController: UIViewController {
urls.forEach { _ in
let progressView = MSProgressView()
self.progressStackView.addArrangedSubview(progressView)
if self.progressViews == nil { self.progressViews = [] }
self.progressViews?.append(progressView)
}
}
Expand Down Expand Up @@ -276,7 +280,6 @@ public final class RewindJourneyViewController: UIViewController {
self.progressViews?[index].isLeftOfCurrentHighlighting = index < presentingIndex ? true : false
self.progressViews?[index].isHighlighted = index <= presentingIndex ? true : false
}
self.restartTimer()
}

// MARK: - Actions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private extension RewindJourneyViewModel {
func startTimer() {
self.timer = Timer.publish(every: self.timerTimeInterval, on: .main, in: .common)
.autoconnect()
.receive(on: DispatchQueue.global(qos: .background))
.sink { [weak self] _ in
self?.state.timerPublisher.send()
}
Expand Down

0 comments on commit f503e88

Please sign in to comment.