From: Alex-Laptop Date: Wed, 18 Sep 2019 16:49:28 +0000 (-0700) Subject: updated view reducer to allow for predefined order in SORT_VIEW X-Git-Tag: v1.0.0~39 X-Git-Url: http://git.infiniteadaptability.org/?a=commitdiff_plain;h=baa89cfa10fdb74f53cf8434ec41270fe3b69e5d;p=workouts updated view reducer to allow for predefined order in SORT_VIEW --- 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]; }