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 { useCallback, useEffect } from 'preact/hooks';
import { parseHypothesisSearchQuery } from '../helpers/query-parser';
import { withServices } from '../service-context'; import { withServices } from '../service-context';
import type { APIService } from '../services/api'; import type { APIService } from '../services/api';
import type { ToastMessengerService } from '../services/toast-messenger'; import type { ToastMessengerService } from '../services/toast-messenger';
import { useSidebarStore } from '../store'; import { useSidebarStore } from '../store';
import { parseHypothesisSearchQuery } from '../util/query-parser';
import ThreadList from './ThreadList'; import ThreadList from './ThreadList';
import { useRootThread } from './hooks/use-root-thread'; import { useRootThread } from './hooks/use-root-thread';
......
...@@ -40,7 +40,7 @@ describe('StreamView', () => { ...@@ -40,7 +40,7 @@ describe('StreamView', () => {
$imports.$mock({ $imports.$mock({
'./hooks/use-root-thread': { useRootThread: fakeUseRootThread }, './hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../store': { useSidebarStore: () => fakeStore }, '../store': { useSidebarStore: () => fakeStore },
'../util/query-parser': fakeQueryParser, '../helpers/query-parser': fakeQueryParser,
}); });
}); });
......
import { cfiInRange, stripCFIAssertions } from '../../shared/cfi'; import { cfiInRange, stripCFIAssertions } from '../../shared/cfi';
import type { Annotation } from '../../types/api'; import type { Annotation } from '../../types/api';
import { pageLabelInRange } from '../util/page-range'; import { pageLabelInRange } from '../util/page-range';
import type { Facet } from '../util/query-parser';
import * as unicodeUtils from '../util/unicode'; import * as unicodeUtils from '../util/unicode';
import { cfi as getCFI, quote, pageLabel } from './annotation-metadata'; import { cfi as getCFI, quote, pageLabel } from './annotation-metadata';
import type { Facet } from './query-parser';
type Filter = { type Filter = {
matches: (ann: Annotation) => boolean; matches: (ann: Annotation) => boolean;
......
import { parseHypothesisSearchQuery, parseFilterQuery } from '../query-parser'; import { parseHypothesisSearchQuery, parseFilterQuery } from '../query-parser';
describe('sidebar/util/query-parser', () => { describe('sidebar/helpers/query-parser', () => {
function isEmptyFilter(filter) { function isEmptyFilter(filter) {
return Object.values(filter).every(value => value.length === 0); return Object.values(filter).every(value => value.length === 0);
} }
......
...@@ -44,7 +44,7 @@ describe('sidebar/helpers/thread-annotations', () => { ...@@ -44,7 +44,7 @@ describe('sidebar/helpers/thread-annotations', () => {
$imports.$mock({ $imports.$mock({
'./build-thread': { buildThread: fakeBuildThread }, './build-thread': { buildThread: fakeBuildThread },
'../util/query-parser': fakeQueryParser, './query-parser': fakeQueryParser,
'./filter-annotations': { filterAnnotations: fakeFilterAnnotations }, './filter-annotations': { filterAnnotations: fakeFilterAnnotations },
}); });
}); });
......
import type { Annotation } from '../../types/api'; import type { Annotation } from '../../types/api';
import { memoize } from '../util/memoize'; import { memoize } from '../util/memoize';
import { parseFilterQuery } from '../util/query-parser';
import { buildThread } from './build-thread'; import { buildThread } from './build-thread';
import type { Thread, BuildThreadOptions } from './build-thread'; import type { Thread, BuildThreadOptions } from './build-thread';
import { filterAnnotations } from './filter-annotations'; import { filterAnnotations } from './filter-annotations';
import { parseFilterQuery } from './query-parser';
import { shouldShowInTab } from './tabs'; import { shouldShowInTab } from './tabs';
import { sorters } from './thread-sorters'; 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