Commit d41ff28d authored by Robert Knight's avatar Robert Knight

Move `src/sidebar/{util/query-parser => helpers/query-parser}`

The loose distinction between `util/` and `helpers/` is that `util/` contains
more general-purpose code that might be useful outside of the client, whereas
`helpers/` contains more app-specific functions. The query parser is really the
latter as it is closely linked to the annotation filtering logic implemented in
`helpers/filter-annotations.ts`.
parent 5d72dda4
import { useCallback, useEffect } from 'preact/hooks';
import { parseHypothesisSearchQuery } from '../helpers/query-parser';
import { withServices } from '../service-context';
import type { APIService } from '../services/api';
import type { ToastMessengerService } from '../services/toast-messenger';
import { useSidebarStore } from '../store';
import { parseHypothesisSearchQuery } from '../util/query-parser';
import ThreadList from './ThreadList';
import { useRootThread } from './hooks/use-root-thread';
......
......@@ -40,7 +40,7 @@ describe('StreamView', () => {
$imports.$mock({
'./hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../store': { useSidebarStore: () => fakeStore },
'../util/query-parser': fakeQueryParser,
'../helpers/query-parser': fakeQueryParser,
});
});
......
import { cfiInRange, stripCFIAssertions } from '../../shared/cfi';
import type { Annotation } from '../../types/api';
import { pageLabelInRange } from '../util/page-range';
import type { Facet } from '../util/query-parser';
import * as unicodeUtils from '../util/unicode';
import { cfi as getCFI, quote, pageLabel } from './annotation-metadata';
import type { Facet } from './query-parser';
type Filter = {
matches: (ann: Annotation) => boolean;
......
import { parseHypothesisSearchQuery, parseFilterQuery } from '../query-parser';
describe('sidebar/util/query-parser', () => {
describe('sidebar/helpers/query-parser', () => {
function isEmptyFilter(filter) {
return Object.values(filter).every(value => value.length === 0);
}
......
......@@ -44,7 +44,7 @@ describe('sidebar/helpers/thread-annotations', () => {
$imports.$mock({
'./build-thread': { buildThread: fakeBuildThread },
'../util/query-parser': fakeQueryParser,
'./query-parser': fakeQueryParser,
'./filter-annotations': { filterAnnotations: fakeFilterAnnotations },
});
});
......
import type { Annotation } from '../../types/api';
import { memoize } from '../util/memoize';
import { parseFilterQuery } from '../util/query-parser';
import { buildThread } from './build-thread';
import type { Thread, BuildThreadOptions } from './build-thread';
import { filterAnnotations } from './filter-annotations';
import { parseFilterQuery } from './query-parser';
import { shouldShowInTab } from './tabs';
import { sorters } from './thread-sorters';
......
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