Browse Source

Select newly added timezone.

pull/92/head
Abhishek 4 years ago
parent
commit
00bf4e1fcb
  1. 15
      Clocker/Preferences/General/PreferencesViewController.swift

15
Clocker/Preferences/General/PreferencesViewController.swift

@ -145,9 +145,9 @@ class PreferencesViewController: ParentViewController {
comment: "Button to close the panel") comment: "Button to close the panel")
} }
@objc func refreshTimezoneTableView() { @objc func refreshTimezoneTableView(_ shouldSelectNewlyInsertedTimezone: Bool = false) {
OperationQueue.main.addOperation { OperationQueue.main.addOperation {
self.build() self.build(shouldSelectNewlyInsertedTimezone)
} }
} }
@ -173,7 +173,7 @@ class PreferencesViewController: ParentViewController {
current.updateTableContent() current.updateTableContent()
} }
private func build() { private func build(_ shouldSelectLastRow: Bool = false) {
if DataStore.shared().timezones() == [] { if DataStore.shared().timezones() == [] {
housekeeping() housekeeping()
return return
@ -186,6 +186,9 @@ class PreferencesViewController: ParentViewController {
timezoneTableView.enclosingScrollView?.isHidden = false timezoneTableView.enclosingScrollView?.isHidden = false
} }
timezoneTableView.reloadData() timezoneTableView.reloadData()
if shouldSelectLastRow {
selectNewlyInsertedTimezone()
}
} else { } else {
housekeeping() housekeeping()
} }
@ -675,7 +678,7 @@ extension PreferencesViewController {
private func updateViewState() { private func updateViewState() {
searchResultsDataSource.cleanupFilterArray() searchResultsDataSource.cleanupFilterArray()
reloadSearchResults() reloadSearchResults()
refreshTimezoneTableView() refreshTimezoneTableView(true)
refreshMainTable() refreshMainTable()
timezonePanel.close() timezonePanel.close()
placeholderLabel.placeholderString = CLEmptyString placeholderLabel.placeholderString = CLEmptyString
@ -795,7 +798,7 @@ extension PreferencesViewController {
searchField.stringValue = CLEmptyString searchField.stringValue = CLEmptyString
reloadSearchResults() reloadSearchResults()
refreshTimezoneTableView() refreshTimezoneTableView(true)
refreshMainTable() refreshMainTable()
timezonePanel.close() timezonePanel.close()
@ -803,8 +806,6 @@ extension PreferencesViewController {
comment: "Search Field Placeholder") comment: "Search Field Placeholder")
availableTimezoneTableView.isHidden = false availableTimezoneTableView.isHidden = false
isActivityInProgress = false isActivityInProgress = false
selectNewlyInsertedTimezone()
} }
private func selectNewlyInsertedTimezone() { private func selectNewlyInsertedTimezone() {

Loading…
Cancel
Save