Skip to content

Commit 40ce517

Browse files
author
Momo Ozawa
committed
Refactor: extract isShowingDashboard to a var
1 parent 46a0d73 commit 40ce517

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

WordPress/Classes/ViewRelated/Blog/My Site/MySiteViewController.swift

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ class MySiteViewController: UIViewController, NoResultsViewHost {
1717
}
1818
}
1919

20+
private var isShowingDashboard: Bool {
21+
return segmentedControl.selectedSegmentIndex == Section.dashboard.rawValue
22+
}
23+
2024
private lazy var scrollView: UIScrollView = {
2125
let scrollView = UIScrollView()
2226
scrollView.translatesAutoresizingMaskIntoConstraints = false
@@ -558,14 +562,17 @@ class MySiteViewController: UIViewController, NoResultsViewHost {
558562

559563
sitePickerViewController.onBlogSwitched = { [weak self] blog in
560564

561-
let isShowingDashboard = self?.segmentedControl.selectedSegmentIndex == Section.dashboard.rawValue
562-
if !blog.isAccessibleThroughWPCom() && isShowingDashboard {
563-
self?.segmentedControl.selectedSegmentIndex = Section.siteMenu.rawValue
564-
self?.segmentedControl.sendActions(for: .valueChanged)
565+
guard let self = self else {
566+
return
567+
}
568+
569+
if !blog.isAccessibleThroughWPCom() && self.isShowingDashboard {
570+
self.segmentedControl.selectedSegmentIndex = Section.siteMenu.rawValue
571+
self.segmentedControl.sendActions(for: .valueChanged)
565572
}
566573

567-
self?.updateSegmentedControl(for: blog)
568-
self?.updateChildViewController(for: blog)
574+
self.updateSegmentedControl(for: blog)
575+
self.updateChildViewController(for: blog)
569576
}
570577

571578
return sitePickerViewController

0 commit comments

Comments
 (0)