Commit e3f9cd9d authored by Alice Wyan's avatar Alice Wyan

Handle Redux store subscriptions on WidgetController destruction

parent f223ceb3
...@@ -93,7 +93,7 @@ module.exports = function WidgetController( ...@@ -93,7 +93,7 @@ module.exports = function WidgetController(
// only those threads, using placeholders above and below the visible threads // only those threads, using placeholders above and below the visible threads
// to reserve space for threads which are not actually rendered. // to reserve space for threads which are not actually rendered.
var visibleThreads = new VirtualThreadList($scope, window, thread()); var visibleThreads = new VirtualThreadList($scope, window, thread());
annotationUI.subscribe(function () { var unsubscribeAnnotationUI = annotationUI.subscribe(function () {
visibleThreads.setRootThread(thread()); visibleThreads.setRootThread(thread());
$scope.selectedTab = annotationUI.getState().selectedTab; $scope.selectedTab = annotationUI.getState().selectedTab;
...@@ -101,6 +101,8 @@ module.exports = function WidgetController( ...@@ -101,6 +101,8 @@ module.exports = function WidgetController(
$scope.totalNotes = countNotes(annotationUI.getState().annotations); $scope.totalNotes = countNotes(annotationUI.getState().annotations);
}); });
$scope.$on('$destroy', unsubscribeAnnotationUI);
visibleThreads.on('changed', function (state) { visibleThreads.on('changed', function (state) {
$scope.virtualThreadList = { $scope.virtualThreadList = {
visibleThreads: state.visibleThreads, visibleThreads: state.visibleThreads,
......
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