Commit 215fd682 authored by Nick Stenning's avatar Nick Stenning

Merge pull request #3169 from hypothesis/t312-do-not-show-clear-btn-whilst-loading

Avoid showing 'Clear Selection' or 'Clear Search' buttons whilst loading
parents fabe1534 9629daba
......@@ -112,6 +112,10 @@ module.exports = function WidgetController(
searchClient.get({uri: uri, group: group});
}
function isLoading() {
return searchClients.length > 0;
}
/**
* Load annotations for all URLs associated with `frames`.
*
......@@ -175,14 +179,11 @@ module.exports = function WidgetController(
});
$scope.$on(events.GROUP_FOCUSED, function () {
// The focused group may be changed during loading annotations (in which
// case, searchClients.length > 0), as a result of switching to the group
// containing the selected annotation.
// The focused group may be changed during loading annotations as a result
// of switching to the group containing a direct-linked annotation.
//
// In that case, we don't want to trigger reloading annotations again and we
// also want to preserve the selection if the user visits a direct link to a
// group annotation whilst signed out, then signs in.
if (searchClients.length) {
// In that case, we don't want to trigger reloading annotations again.
if (isLoading()) {
return;
}
......@@ -206,7 +207,7 @@ module.exports = function WidgetController(
};
$scope.selectedAnnotationUnavailable = function () {
return searchClients.length === 0 &&
return !isLoading() &&
annotationUI.hasSelectedAnnotations() &&
!threading.idTable[firstKey(annotationUI.selectedAnnotationMap)];
};
......@@ -226,11 +227,13 @@ module.exports = function WidgetController(
// The user is logged out and has landed on a direct linked
// annotation. If there is an annotation selection and that
// selection is available to the user, show the CTA.
return searchClients.length === 0 &&
return !isLoading() &&
annotationUI.hasSelectedAnnotations() &&
!!threading.idTable[firstKey(annotationUI.selectedAnnotationMap)];
};
$scope.isLoading = isLoading;
$rootScope.$on(events.BEFORE_ANNOTATION_CREATED, function (event, data) {
if (data.$highlight || (data.references && data.references.length > 0)) {
return;
......
......@@ -12,7 +12,8 @@
filter-match-count="count('match')"
search-query="search ? search.query : ''"
selection-count="selectedAnnotationsCount"
on-clear-selection="clearSelection()">
on-clear-selection="clearSelection()"
ng-show="!isLoading()">
</search-status-bar>
<li ng-if="isStream">
<sort-dropdown
......
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