key => key !== 'id' && locationQuery[key] !== ''
);
- // if there is no filter, but there are saved preferences in the localStorage
const graph = getGraph();
- return !filtered && graph != null && graph !== DEFAULT_GRAPH;
+ const emptyCustomGraph = isCustomGraph(graph) && getCustomGraph().length <= 0;
+
+ // if there is no filter, but there are saved preferences in the localStorage
+ // also don't redirect to custom if there is no metrics selected for it
+ return !filtered && graph != null && graph !== DEFAULT_GRAPH && !emptyCustomGraph;
}
};
export const saveCustomGraph = (metrics: ?Array<string>) =>
save(PROJECT_ACTIVITY_GRAPH_CUSTOM, metrics ? metrics.join(',') : '');
-export const getCustomGraph = (): Array<string> =>
- (window.localStorage.getItem(PROJECT_ACTIVITY_GRAPH_CUSTOM) || '').split(',');
+export const getCustomGraph = (): Array<string> => {
+ const customGraphs = window.localStorage.getItem(PROJECT_ACTIVITY_GRAPH_CUSTOM);
+ return customGraphs ? customGraphs.split(',') : [];
+};
export const saveGraph = (graph: ?string) => save(PROJECT_ACTIVITY_GRAPH, graph);
export const getGraph = (): string =>