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