Commit 5888fd96 authored by Robert Knight's avatar Robert Knight

Use `watch` utility to simplify `stream-content`

parent 6dc9ad86
import { watch } from '../util/watch';
// @ngInject // @ngInject
function StreamContentController($scope, store, api, rootThread, searchFilter) { function StreamContentController($scope, store, api, rootThread, searchFilter) {
/** `offset` parameter for the next search API call. */ /** `offset` parameter for the next search API call. */
...@@ -43,13 +45,8 @@ function StreamContentController($scope, store, api, rootThread, searchFilter) { ...@@ -43,13 +45,8 @@ function StreamContentController($scope, store, api, rootThread, searchFilter) {
fetch(20); fetch(20);
} }
let lastQuery = currentQuery(); const unsubscribe = watch(store.subscribe, currentQuery, () => {
const unsubscribe = store.subscribe(() => {
const query = currentQuery();
if (query !== lastQuery) {
lastQuery = query;
clearAndFetch(); clearAndFetch();
}
}); });
$scope.$on('$destroy', unsubscribe); $scope.$on('$destroy', unsubscribe);
......
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