diff --git a/lib/flux/app-state.ts b/lib/flux/app-state.ts index bb4962adf..b351c7505 100644 --- a/lib/flux/app-state.ts +++ b/lib/flux/app-state.ts @@ -37,7 +37,6 @@ const initialState: AppState = { notes: null, tags: [], revision: null, - showTrash: false, showNavigation: false, dialogs: [], nextDialogKey: 0, @@ -85,7 +84,6 @@ export const actionMap = new ActionMap({ showAllNotes(state: AppState) { return update(state, { showNavigation: { $set: false }, - showTrash: { $set: false }, tag: { $set: null }, previousIndex: { $set: -1 }, }); @@ -94,7 +92,6 @@ export const actionMap = new ActionMap({ selectTrash(state: AppState) { return update(state, { showNavigation: { $set: false }, - showTrash: { $set: true }, tag: { $set: null }, previousIndex: { $set: -1 }, }); @@ -116,7 +113,6 @@ export const actionMap = new ActionMap({ selectTag(state: AppState, { tag }: { tag: T.TagEntity }) { return update(state, { showNavigation: { $set: false }, - showTrash: { $set: false }, tag: { $set: tag }, previousIndex: { $set: -1 }, }); @@ -176,10 +172,6 @@ export const actionMap = new ActionMap({ const { appState: state, settings } = getState(); const timestamp = new Date().getTime() / 1000; - if (state.showTrash) { - dispatch(this.action('showAllNotes')); - } - // insert a new note into the store and select it noteBucket.add( { diff --git a/lib/navigation-bar/index.tsx b/lib/navigation-bar/index.tsx index fac251c4b..32ecb144d 100644 --- a/lib/navigation-bar/index.tsx +++ b/lib/navigation-bar/index.tsx @@ -127,12 +127,12 @@ export class NavigationBar extends Component { } } -const mapStateToProps = ({ appState: state, settings }) => ({ +const mapStateToProps = ({ appState: state, settings, ui: { showTrash } }) => ({ autoHideMenuBar: settings.autoHideMenuBar, dialogs: state.dialogs, selectedTag: state.tag, showNavigation: state.showNavigation, - showTrash: state.showTrash, + showTrash, }); const { diff --git a/lib/note-list/index.tsx b/lib/note-list/index.tsx index 6ce21414c..37d8e6dab 100644 --- a/lib/note-list/index.tsx +++ b/lib/note-list/index.tsx @@ -480,7 +480,7 @@ const { recordEvent } = tracks; const mapStateToProps: S.MapState = ({ appState: state, - ui: { filteredNotes, note, searchQuery }, + ui: { filteredNotes, note, searchQuery, showTrash }, settings: { noteDisplay }, }) => { const tagResultsFound = getMatchingTags(state.tags, searchQuery).length; @@ -535,7 +535,7 @@ const mapStateToProps: S.MapState = ({ selectedNotePreview, selectedNoteContent: get(selectedNote, 'data.content'), selectedNoteId, - showTrash: state.showTrash, + showTrash, tagResultsFound, }; }; diff --git a/lib/search-bar/index.tsx b/lib/search-bar/index.tsx index 7501ea3ea..d9b28d404 100644 --- a/lib/search-bar/index.tsx +++ b/lib/search-bar/index.tsx @@ -52,8 +52,7 @@ export const SearchBar: FunctionComponent = ({ ); const mapStateToProps: S.MapState = ({ - appState: { showTrash }, - ui: { searchQuery }, + ui: { searchQuery, showTrash }, }) => ({ searchQuery, showTrash, diff --git a/lib/state/index.ts b/lib/state/index.ts index e680939eb..4083606db 100644 --- a/lib/state/index.ts +++ b/lib/state/index.ts @@ -37,7 +37,6 @@ export type AppState = { revision: T.NoteEntity | null; searchFocus: boolean; showNavigation: boolean; - showTrash: boolean; tags: T.TagEntity[]; tag?: T.TagEntity; unsyncedNoteIds: T.EntityId[]; diff --git a/lib/state/ui/reducer.ts b/lib/state/ui/reducer.ts index f0f0927a0..c7179717e 100644 --- a/lib/state/ui/reducer.ts +++ b/lib/state/ui/reducer.ts @@ -100,6 +100,20 @@ const showRevisions: A.Reducer = (state = false, action) => { } }; +const showTrash: A.Reducer = (state = false, action) => { + switch (action.type) { + case 'App.selectTrash': + return true; + case 'CREATE_NOTE': + case 'App.selectTag': + case 'App.showAllNotes': { + return false; + } + default: + return state; + } +}; + const note: A.Reducer = (state = null, action) => { switch (action.type) { case 'App.selectNote': @@ -133,6 +147,7 @@ export default combineReducers({ showNoteInfo, showNoteList, showRevisions, + showTrash, simperiumConnected, unsyncedNoteIds, }); diff --git a/lib/utils/filter-notes.ts b/lib/utils/filter-notes.ts index 386a623c6..8afcd0261 100644 --- a/lib/utils/filter-notes.ts +++ b/lib/utils/filter-notes.ts @@ -114,8 +114,8 @@ export default function filterNotes( notesArray: T.NoteEntity[] | null = null ) { const { - appState: { notes, showTrash, tag }, - ui: { searchQuery }, + appState: { notes, tag }, + ui: { searchQuery, showTrash }, } = state; const notesToFilter = notesArray ? notesArray : notes;