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() { 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. // Check if another instance of the app is already running. If so, then stop this one.
checkIfAppIsAlreadyOpen() checkIfAppIsAlreadyOpen()

8
Clocker/Onboarding/OnboardingParentViewController.swift

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

15
Clocker/Onboarding/OnboardingSearchController.swift

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

2
Clocker/Preferences/General/SearchDataSource.swift

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

Loading…
Cancel
Save