diff --git a/src/filters.ts b/src/filters.ts index 66937d83..4948449a 100644 --- a/src/filters.ts +++ b/src/filters.ts @@ -144,6 +144,9 @@ const MISSING_CONCEPT_FILTER_NAME = 'missing-concept'; const SAME_TYPE_FILTER_NAME = 'same-type'; const DIFFERENT_TYPE_FILTER_NAME = 'different-type'; +export const SELECTED_FILTER_NAME = 'selected'; +const NOT_SELECTED_FILTER_NAME = 'not-selected'; + /* * filterEquivalent - the name of the filter that, when applied to the everything set, will filter down to contain just the items in that set (although @@ -1991,6 +1994,7 @@ export const INVERSE_FILTER_NAMES = Object.assign( { 'unstarred': 'starred', 'unread': 'read', + [NOT_SELECTED_FILTER_NAME]: SELECTED_FILTER_NAME, [ALL_FILTER_NAME]: NONE_FILTER_NAME, [TODO_COMBINED_INVERSE_FILTER_NAME]: TODO_COMBINED_FILTER_NAME, }, diff --git a/src/selectors.ts b/src/selectors.ts index eb126b51..5335df3e 100644 --- a/src/selectors.ts +++ b/src/selectors.ts @@ -25,7 +25,8 @@ import { limitFilter, excludeFilter, cardsFilter, - cardTypeFilter + cardTypeFilter, + SELECTED_FILTER_NAME } from './filters.js'; import { @@ -155,7 +156,8 @@ import { ViewMode, ReferenceType, SortExtra, - CardDiff + CardDiff, + Filters } from './types.js'; import { @@ -231,7 +233,7 @@ export const selectEditorMinimized = (state : State) => state.editor ? state.edi export const selectEditingUpdatedFromContentEditable = (state : State) => state.editor ? state.editor.updatedFromContentEditable : {}; export const selectEditingPendingReferenceType = (state : State) : ReferenceType => state.editor ? state.editor.pendingReferenceType : 'ack'; export const selectPendingSlug = (state : State) => state.editor ? state.editor.pendingSlug : ''; -export const selectFilters = (state : State) => state.collection ? state.collection.filters : {}; +const selectBaseFilters = (state : State) => state.collection ? state.collection.filters : {}; const selectFiltersSnapshot = (state : State) => state.collection ? state.collection.filtersSnapshot : {}; export const selectSections = (state : State) => state.data ? state.data.sections : {}; export const selectTags = (state : State) => state.data ? state.data.tags : {}; @@ -431,6 +433,15 @@ export const selectKeyboardNavigates = createSelector( (editing, find, compose) => !editing && !find && !compose ); +export const selectFilters = createSelector( + selectBaseFilters, + selectExplicitlySelectedCardIDs, + (baseFilters, selectedCards) : Filters => ({ + ...baseFilters, + [SELECTED_FILTER_NAME]: selectedCards + }) +); + //This is just the userPermissions fetched; for the actual permissions object in //use, see selectCOmposedPermissions. const selectUserPermissions = (state : State) => state.user ? state.user.userPermissions : {};