Unverified Commit e8cb9e3c authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #1273 from hypothesis/simplify-thread-generation

Simplify root thread generation in top-level UI components
parents 83d36a7b 8c106e9c
......@@ -36,15 +36,11 @@ function AnnotationViewerContentController(
streamFilter,
annotationMapper
) {
const self = this;
store.setAppIsSidebar(false);
const id = $routeParams.id;
store.subscribe(function() {
self.rootThread = rootThread.thread(store.getState());
});
this.rootThread = () => rootThread.thread(store.getState());
this.setCollapsed = function(id, collapsed) {
store.setCollapsed(id, collapsed);
......
......@@ -17,15 +17,7 @@ function SidebarContentController(
) {
const self = this;
function thread() {
return rootThread.thread(store.getState());
}
const unsubscribeAnnotationUI = store.subscribe(function() {
self.rootThread = thread();
});
$scope.$on('$destroy', unsubscribeAnnotationUI);
this.rootThread = () => rootThread.thread(store.getState());
function focusAnnotation(annotation) {
let highlights = [];
......
......@@ -11,8 +11,6 @@ function StreamContentController(
rootThread,
searchFilter
) {
const self = this;
store.setAppIsSidebar(false);
/** `offset` parameter for the next search API call. */
......@@ -62,10 +60,7 @@ function StreamContentController(
fetch(20);
this.setCollapsed = store.setCollapsed;
store.subscribe(function() {
self.rootThread = rootThread.thread(store.getState());
});
this.rootThread = () => rootThread.thread(store.getState());
// Sort the stream so that the newest annotations are at the top
store.setSortKey('Newest');
......
......@@ -164,6 +164,11 @@ describe('sidebar.components.sidebar-content', function() {
fakeAnnotations.load.reset();
}
it('generates the thread list', () => {
const thread = fakeRootThread.thread(store.getState());
assert.equal(ctrl.rootThread(), thread);
});
context('when the search URIs of connected frames change', () => {
beforeEach(connectFrameAndPerformInitialFetch);
......
......@@ -2,5 +2,5 @@
on-change-collapsed="vm.setCollapsed(id, collapsed)"
on-force-visible="vm.forceVisible(thread)"
show-document-info="true"
thread="vm.rootThread">
thread="vm.rootThread()">
</thread-list>
......@@ -35,7 +35,7 @@
on-select="vm.scrollTo(annotation)"
show-document-info="false"
ng-if="!vm.selectedGroupUnavailable()"
thread="vm.rootThread">
thread="vm.rootThread()">
</thread-list>
<logged-out-message ng-if="vm.shouldShowLoggedOutMessage()" on-login="vm.onLogin()">
......
......@@ -2,6 +2,6 @@
<thread-list
on-change-collapsed="vm.setCollapsed(id, collapsed)"
show-document-info="true"
thread="vm.rootThread">
thread="vm.rootThread()">
</thread-list>
</span>
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