Commit 817d82f4 authored by Robert Knight's avatar Robert Knight

Optimize `sortKeys` selector

This was recomputing frequently even though the result only changes when
the selected tab changes.
parent 945825da
...@@ -362,16 +362,19 @@ function sortKey(state) { ...@@ -362,16 +362,19 @@ function sortKey(state) {
/** /**
* Retrieve applicable sort options for the currently-selected tab. * Retrieve applicable sort options for the currently-selected tab.
* *
* @return {string[]} * @type {(state: any) => string[]}
*/ */
function sortKeys(state) { const sortKeys = createSelector(
const sortKeysForTab = ['Newest', 'Oldest']; state => state.selectedTab,
if (state.selectedTab !== uiConstants.TAB_NOTES) { selectedTab => {
// Location is inapplicable to Notes tab const sortKeysForTab = ['Newest', 'Oldest'];
sortKeysForTab.push('Location'); if (selectedTab !== uiConstants.TAB_NOTES) {
// Location is inapplicable to Notes tab
sortKeysForTab.push('Location');
}
return sortKeysForTab;
} }
return sortKeysForTab; );
}
/** /**
* @typedef SelectionStore * @typedef SelectionStore
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment