Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

Commit

Permalink
Debounce refresh when resuming from background
Browse files Browse the repository at this point in the history
  • Loading branch information
jzzocc committed Nov 28, 2022
1 parent bdd63e2 commit ce6d550
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions View Controllers/MainNavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ final class MainNavigationViewController: UITabBarController {
.store(in: &cancellables)

NotificationCenter.default.publisher(for: UIScene.willEnterForegroundNotification)
.debounce(for: .seconds(Self.refreshFromBackgroundDebounceInterval), scheduler: DispatchQueue.main)
.sink { [weak self] _ in self?.viewModel.refreshIdentity() }
.store(in: &cancellables)
}
Expand Down Expand Up @@ -106,6 +107,7 @@ extension MainNavigationViewController: NavigationHandling {
private extension MainNavigationViewController {
static let secondaryNavigationViewTag = UUID().hashValue
static let newStatusViewTag = UUID().hashValue
static let refreshFromBackgroundDebounceInterval: TimeInterval = 30

func setupViewControllers(pending: Bool) {
var controllers: [UIViewController] = [
Expand Down

0 comments on commit ce6d550

Please sign in to comment.