From baa89cfa10fdb74f53cf8434ec41270fe3b69e5d Mon Sep 17 00:00:00 2001 From: Alex-Laptop Date: Wed, 18 Sep 2019 09:49:28 -0700 Subject: [PATCH] updated view reducer to allow for predefined order in SORT_VIEW --- src/components/main/main.js | 1 + src/reducers/view.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/main/main.js b/src/components/main/main.js index e6dd15a..32de7fb 100644 --- a/src/components/main/main.js +++ b/src/components/main/main.js @@ -30,6 +30,7 @@ const mapDispatchToProps = (dispatch,ownProps) => { dispatch({ type:SORT_VIEW, key:(view=="manage")?"last_done":"date", + order:(view==="manage")?"asc":"desc", shift:false }); } diff --git a/src/reducers/view.js b/src/reducers/view.js index 6152197..74a07d0 100644 --- a/src/reducers/view.js +++ b/src/reducers/view.js @@ -104,11 +104,14 @@ export default function view(state = defaultState,action) { newSortKey.push(action.key); newSortOrder.push("asc"); } + } else if(action.order!==void(0)) { + newSortOrder = (action.order==="asc")?["asc"]:["desc"]; + newSortKey = [action.key]; } else { if((newSortKey[0] !== void(0))&&(newSortKey[0]==action.key)) { newSortOrder = (newSortOrder[0]=="asc")?["desc"]:["asc"]; } else { - newSortOrder = ["desc"]; + newSortOrder = ["asc"]; } newSortKey = [action.key]; } -- 2.30.2