]> infiniteadaptability.org Git - workouts/commitdiff
updated view reducer to allow for predefined order in SORT_VIEW
authorAlex-Laptop <[email protected]>
Wed, 18 Sep 2019 16:49:28 +0000 (09:49 -0700)
committerAlex-Laptop <[email protected]>
Wed, 18 Sep 2019 16:49:28 +0000 (09:49 -0700)
src/components/main/main.js
src/reducers/view.js

index e6dd15a803fd3cb02e95008268248651d273c21c..32de7fb1e2400ced29a847480e42b73f9b7507c6 100644 (file)
@@ -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
                        });
                }
index 6152197368ceda34dc9eea8ac146e7af79050b91..74a07d04738a4820462c6e9721f6378bbea9cbde 100644 (file)
@@ -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];
                        }