Skip to content

Commit

Permalink
Merge pull request #481 from hypothesis/dont-show-view-switcher-until…
Browse files Browse the repository at this point in the history
…-first-batch-of-annotations-received

Don't show view switcher until annotations received
  • Loading branch information
robertknight authored Jul 5, 2017
2 parents 84d4b3f + f240476 commit 0c4a7c7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/sidebar/components/test/view-switcher-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ describe('viewSwitcher', function () {
});

beforeEach(function () {
var fakeAnnotationUI = {};
var fakeAnnotationUI = {
getState: sinon.stub().returns({
frames: [
{
// The view switcher only shows after the first batch of
// annotations have been fetched.
isAnnotationFetchComplete: true,
},
],
}),
};
var fakeFeatures = {
flagEnabled: sinon.stub().returns(true),
};
Expand Down
8 changes: 8 additions & 0 deletions src/sidebar/components/view-switcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ module.exports = {
return features.flagEnabled('orphans_tab');
};

this.showViewSwitcher = function() {
var frame = annotationUI.getState().frames[0];
if (frame && frame.isAnnotationFetchComplete) {
return true;
}
return false;
};

this.showAnnotationsUnavailableMessage = function () {
return this.selectedTab === this.TAB_ANNOTATIONS &&
this.totalAnnotations === 0 &&
Expand Down
2 changes: 1 addition & 1 deletion src/sidebar/templates/view-switcher.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="view-switcher">
<div class="view-switcher" ng-if="vm.showViewSwitcher()">
<button class="view-switcher__tab"
ng-class="{'is-selected': vm.selectedTab === vm.TAB_ANNOTATIONS}"
h-on-touch="vm.selectTab(vm.TAB_ANNOTATIONS)">
Expand Down

0 comments on commit 0c4a7c7

Please sign in to comment.