Commit cca9dabd authored by Hannah Stepanek's avatar Hannah Stepanek

Default sidebar tab to notes when only page notes

Change the default tab to focus on page notes when there are
no annotations and only page notes in a group. This way it
directs the user where they need to go. Less clicking == yay!
If there are no annotations at all, the annotations tab should
be selected.
parent 99d764ab
......@@ -14,6 +14,7 @@ var immutable = require('seamless-immutable');
var toSet = require('../util/array-util').toSet;
var uiConstants = require('../ui-constants');
var tabs = require('../tabs');
var util = require('./util');
......@@ -132,6 +133,17 @@ var update = {
};
},
ADD_ANNOTATIONS(state, action) {
var counts = tabs.counts(action.annotations);
// If there are no annotations at all, ADD_ANNOTATIONS will not be called.
var haveOnlyPageNotes = counts.notes === action.annotations.length;
// If this is the init phase and there are only page notes, select the page notes tab.
if (state.annotations.length === 0 && haveOnlyPageNotes){
return {selectedTab: uiConstants.TAB_NOTES};
}
return {};
},
SET_FILTER_QUERY: function (state, action) {
return {
filterQuery: action.query,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment