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(
state => state.selectedTab,
selectedTab => {
const sortKeysForTab = ['Newest', 'Oldest']; const sortKeysForTab = ['Newest', 'Oldest'];
if (state.selectedTab !== uiConstants.TAB_NOTES) { if (selectedTab !== uiConstants.TAB_NOTES) {
// Location is inapplicable to Notes tab // Location is inapplicable to Notes tab
sortKeysForTab.push('Location'); 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