Browse Source

Allocations optimization.

pull/113/head
Abhishek Banthia 3 years ago
parent
commit
2e0185e6f6
  1. 5
      Clocker/AppDelegate.swift
  2. 8
      Clocker/Onboarding/OnboardingParentViewController.swift
  3. 15
      Clocker/Onboarding/OnboardingSearchController.swift
  4. 2
      Clocker/Preferences/General/SearchDataSource.swift

5
Clocker/AppDelegate.swift

@ -106,6 +106,11 @@ open class AppDelegate: NSObject, NSApplicationDelegate {
}
func continueUsually() {
// Cleanup onboarding controller after its done!
if controller != nil {
controller = nil
}
// Check if another instance of the app is already running. If so, then stop this one.
checkIfAppIsAlreadyOpen()

8
Clocker/Onboarding/OnboardingParentViewController.swift

@ -218,15 +218,15 @@ class OnboardingParentViewController: NSViewController {
func performFinalStepsBeforeFinishing() {
positiveButton.tag = OnboardingType.complete.rawValue
// Install the menubar option!
let appDelegate = NSApplication.shared.delegate as? AppDelegate
appDelegate?.continueUsually()
view.window?.close()
if ProcessInfo.processInfo.arguments.contains(CLOnboaringTestsLaunchArgument) == false {
UserDefaults.standard.set(true, forKey: CLShowOnboardingFlow)
}
// Install the menubar option!
let appDelegate = NSApplication.shared.delegate as? AppDelegate
appDelegate?.continueUsually()
}
private func addChildIfNeccessary(_ viewController: NSViewController) {

15
Clocker/Onboarding/OnboardingSearchController.swift

@ -40,8 +40,7 @@ class OnboardingSearchController: NSViewController {
super.viewDidLoad()
view.wantsLayer = true
searchResultsDataSource = SearchDataSource(with: searchBar, location: .onboarding)
resultsTableView.isHidden = true
resultsTableView.delegate = self
resultsTableView.setAccessibility("ResultsTableView")
@ -70,6 +69,16 @@ class OnboardingSearchController: NSViewController {
setupUndoButton()
}
override func viewWillAppear() {
super.viewWillAppear()
searchResultsDataSource = SearchDataSource(with: searchBar, location: .onboarding)
}
override func viewWillDisappear() {
super.viewWillDisappear()
searchResultsDataSource = nil
}
deinit {
if let themeDidChangeNotif = themeDidChangeNotification {
@ -440,7 +449,7 @@ class OnboardingSearchController: NSViewController {
extension OnboardingSearchController: NSTableViewDataSource {
func numberOfRows(in _: NSTableView) -> Int {
return searchResultsDataSource.resultsCount()
return searchResultsDataSource != nil ? searchResultsDataSource.resultsCount() : 0
}
func tableView(_ tableView: NSTableView, viewFor _: NSTableColumn?, row: Int) -> NSView? {

2
Clocker/Preferences/General/SearchDataSource.swift

@ -21,7 +21,7 @@ struct TimezoneMetadata {
}
class SearchDataSource: NSObject {
private var searchField: NSSearchField!
private weak var searchField: NSSearchField!
private var finalArray: [RowType] = []
private var location: SearchLocation = .preferences
private var dataTask: URLSessionDataTask? = .none

Loading…
Cancel
Save