Commit d2344538 authored by Robert Knight's avatar Robert Knight

Use a named export for `StreamFilter` class

Update `StreamFilter` class to current service conventions. Part of
https://github.com/hypothesis/client/issues/3298.
parent e1c0532a
...@@ -109,7 +109,7 @@ import persistedDefaultsService from './services/persisted-defaults'; ...@@ -109,7 +109,7 @@ import persistedDefaultsService from './services/persisted-defaults';
import { RouterService } from './services/router'; import { RouterService } from './services/router';
import serviceUrlService from './services/service-url'; import serviceUrlService from './services/service-url';
import sessionService from './services/session'; import sessionService from './services/session';
import streamFilterService from './services/stream-filter'; import { StreamFilter } from './services/stream-filter';
import streamerService from './services/streamer'; import streamerService from './services/streamer';
import tagsService from './services/tags'; import tagsService from './services/tags';
import threadsService from './services/threads'; import threadsService from './services/threads';
...@@ -148,7 +148,7 @@ function startApp(config, appEl) { ...@@ -148,7 +148,7 @@ function startApp(config, appEl) {
.register('serviceUrl', serviceUrlService) .register('serviceUrl', serviceUrlService)
.register('session', sessionService) .register('session', sessionService)
.register('streamer', streamerService) .register('streamer', streamerService)
.register('streamFilter', streamFilterService) .register('streamFilter', StreamFilter)
.register('tags', tagsService) .register('tags', tagsService)
.register('threadsService', threadsService) .register('threadsService', threadsService)
.register('toastMessenger', ToastMessengerService) .register('toastMessenger', ToastMessengerService)
......
...@@ -33,7 +33,7 @@ import { isReply } from '../helpers/annotation-metadata'; ...@@ -33,7 +33,7 @@ import { isReply } from '../helpers/annotation-metadata';
* @param {ReturnType<import('./api').default>} api * @param {ReturnType<import('./api').default>} api
* @param {import('../store').SidebarStore} store * @param {import('../store').SidebarStore} store
* @param {import('./streamer').default} streamer * @param {import('./streamer').default} streamer
* @param {import('./stream-filter').default} streamFilter * @param {import('./stream-filter').StreamFilter} streamFilter
*/ */
// @inject // @inject
export default function loadAnnotationsService( export default function loadAnnotationsService(
......
...@@ -44,9 +44,9 @@ function defaultFilter() { ...@@ -44,9 +44,9 @@ function defaultFilter() {
* See https://github.com/hypothesis/h/blob/master/h/streamer/filter.py * See https://github.com/hypothesis/h/blob/master/h/streamer/filter.py
* for the schema. * for the schema.
*/ */
export default class StreamFilter { export class StreamFilter {
constructor() { constructor() {
this.filter = defaultFilter(); this._filter = defaultFilter();
} }
/** /**
...@@ -58,7 +58,7 @@ export default class StreamFilter { ...@@ -58,7 +58,7 @@ export default class StreamFilter {
* @param {FilterClause['case_sensitive']} caseSensitive - Whether matching should be case sensitive * @param {FilterClause['case_sensitive']} caseSensitive - Whether matching should be case sensitive
*/ */
addClause(field, operator, value, caseSensitive = false) { addClause(field, operator, value, caseSensitive = false) {
this.filter.clauses.push({ this._filter.clauses.push({
field, field,
operator, operator,
value, value,
...@@ -69,12 +69,12 @@ export default class StreamFilter { ...@@ -69,12 +69,12 @@ export default class StreamFilter {
/** Return the JSON-serializable filtering configuration. */ /** Return the JSON-serializable filtering configuration. */
getFilter() { getFilter() {
return this.filter; return this._filter;
} }
/** Reset the configuration to return all updates. */ /** Reset the configuration to return all updates. */
resetFilter() { resetFilter() {
this.filter = defaultFilter(); this._filter = defaultFilter();
return this; return this;
} }
} }
import StreamFilter from '../stream-filter'; import { StreamFilter } from '../stream-filter';
describe('sidebar/services/stream-filter', () => { describe('StreamFilter', () => {
describe('#addClause', () => { describe('#addClause', () => {
[ [
{ {
......
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