From 6793325b3854af949c9a9c00e587e84b3d75eac6 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Sat, 14 Sep 2019 16:22:42 -0700 Subject: [PATCH] Trimming logic. --- .../General/PreferencesViewController.swift | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/Clocker/Preferences/General/PreferencesViewController.swift b/Clocker/Preferences/General/PreferencesViewController.swift index 1dcc4ef..747e36e 100644 --- a/Clocker/Preferences/General/PreferencesViewController.swift +++ b/Clocker/Preferences/General/PreferencesViewController.swift @@ -803,21 +803,12 @@ extension PreferencesViewController { let data = TimezoneData() data.setLabel(CLEmptyString) - if searchField.stringValue.isEmpty == false { - let currentSelection = searchResultsDataSource.timezoneFilteredArray[availableTimezoneTableView.selectedRow % searchResultsDataSource.timezoneFilteredArray.count] - - let metaInfo = metadata(for: currentSelection) - data.timezoneID = metaInfo.0.name - data.formattedAddress = metaInfo.1.formattedName - - } else { - let currentSelection = searchResultsDataSource.timezoneArray[availableTimezoneTableView.selectedRow - 1] - - let metaInfo = metadata(for: currentSelection) - data.timezoneID = metaInfo.0.name - data.formattedAddress = metaInfo.1.formattedName - } + let currentSelection = searchField.stringValue.isEmpty == false ? searchResultsDataSource.timezoneFilteredArray[availableTimezoneTableView.selectedRow % searchResultsDataSource.timezoneFilteredArray.count] : + searchResultsDataSource.timezoneArray[availableTimezoneTableView.selectedRow - 1] + let metaInfo = metadata(for: currentSelection) + data.timezoneID = metaInfo.0.name + data.formattedAddress = metaInfo.1.formattedName data.selectionType = .timezone let operationObject = TimezoneDataOperations(with: data)