Commit e1408b36 authored by Eduardo Sanz García's avatar Eduardo Sanz García Committed by Eduardo

`useRootThread` Preact hook: convert to named export

parent 4157859d
...@@ -2,7 +2,7 @@ import { useEffect, useState } from 'preact/hooks'; ...@@ -2,7 +2,7 @@ import { useEffect, useState } from 'preact/hooks';
import { useStoreProxy } from '../store/use-store'; import { useStoreProxy } from '../store/use-store';
import { withServices } from '../service-context'; import { withServices } from '../service-context';
import useRootThread from './hooks/use-root-thread'; import { useRootThread } from './hooks/use-root-thread';
import ThreadList from './ThreadList'; import ThreadList from './ThreadList';
import SidebarContentError from './SidebarContentError'; import SidebarContentError from './SidebarContentError';
......
...@@ -5,7 +5,7 @@ import { useMemo } from 'preact/hooks'; ...@@ -5,7 +5,7 @@ import { useMemo } from 'preact/hooks';
import { countVisible } from '../helpers/thread'; import { countVisible } from '../helpers/thread';
import { useStoreProxy } from '../store/use-store'; import { useStoreProxy } from '../store/use-store';
import useRootThread from './hooks/use-root-thread'; import { useRootThread } from './hooks/use-root-thread';
/** /**
* @typedef {import('../helpers/build-thread').Thread} Thread * @typedef {import('../helpers/build-thread').Thread} Thread
......
import { Spinner } from '@hypothesis/frontend-shared'; import { Spinner } from '@hypothesis/frontend-shared';
import useRootThread from './hooks/use-root-thread'; import { useRootThread } from './hooks/use-root-thread';
import { countVisible } from '../helpers/thread'; import { countVisible } from '../helpers/thread';
/** /**
......
...@@ -9,7 +9,7 @@ import { useStoreProxy } from '../store/use-store'; ...@@ -9,7 +9,7 @@ import { useStoreProxy } from '../store/use-store';
import NotebookFilters from './NotebookFilters'; import NotebookFilters from './NotebookFilters';
import NotebookResultCount from './NotebookResultCount'; import NotebookResultCount from './NotebookResultCount';
import PaginatedThreadList from './PaginatedThreadList'; import PaginatedThreadList from './PaginatedThreadList';
import useRootThread from './hooks/use-root-thread'; import { useRootThread } from './hooks/use-root-thread';
/** /**
* @typedef NotebookViewProps * @typedef NotebookViewProps
......
import { useEffect, useRef } from 'preact/hooks'; import { useEffect, useRef } from 'preact/hooks';
import useRootThread from './hooks/use-root-thread'; import { useRootThread } from './hooks/use-root-thread';
import { withServices } from '../service-context'; import { withServices } from '../service-context';
import { useStoreProxy } from '../store/use-store'; import { useStoreProxy } from '../store/use-store';
import { tabForAnnotation } from '../helpers/tabs'; import { tabForAnnotation } from '../helpers/tabs';
......
...@@ -2,7 +2,7 @@ import { useCallback, useEffect } from 'preact/hooks'; ...@@ -2,7 +2,7 @@ import { useCallback, useEffect } from 'preact/hooks';
import * as searchFilter from '../util/search-filter'; import * as searchFilter from '../util/search-filter';
import { withServices } from '../service-context'; import { withServices } from '../service-context';
import useRootThread from './hooks/use-root-thread'; import { useRootThread } from './hooks/use-root-thread';
import { useStoreProxy } from '../store/use-store'; import { useStoreProxy } from '../store/use-store';
import ThreadList from './ThreadList'; import ThreadList from './ThreadList';
......
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import useRootThread, { $imports } from '../use-root-thread'; import { useRootThread, $imports } from '../use-root-thread';
describe('sidebar/components/hooks/use-root-thread', () => { describe('sidebar/components/hooks/use-root-thread', () => {
let fakeStore; let fakeStore;
......
...@@ -11,7 +11,7 @@ import { threadAnnotations } from '../../helpers/thread-annotations'; ...@@ -11,7 +11,7 @@ import { threadAnnotations } from '../../helpers/thread-annotations';
* *
* @return {Thread} * @return {Thread}
*/ */
export default function useRootThread() { export function useRootThread() {
const store = useStoreProxy(); const store = useStoreProxy();
const annotations = store.allAnnotations(); const annotations = store.allAnnotations();
const query = store.filterQuery(); const query = store.filterQuery();
......
...@@ -2,7 +2,6 @@ import { mount } from 'enzyme'; ...@@ -2,7 +2,6 @@ import { mount } from 'enzyme';
import { waitFor } from '../../../test-util/wait'; import { waitFor } from '../../../test-util/wait';
import { mockImportedComponents } from '../../../test-util/mock-imported-components'; import { mockImportedComponents } from '../../../test-util/mock-imported-components';
import AnnotationView, { $imports } from '../AnnotationView'; import AnnotationView, { $imports } from '../AnnotationView';
describe('AnnotationView', () => { describe('AnnotationView', () => {
...@@ -32,7 +31,7 @@ describe('AnnotationView', () => { ...@@ -32,7 +31,7 @@ describe('AnnotationView', () => {
$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
$imports.$mock({ $imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread, './hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../store/use-store': { useStoreProxy: () => fakeStore }, '../store/use-store': { useStoreProxy: () => fakeStore },
}); });
}); });
......
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import FilterStatus, { $imports } from '../FilterStatus';
import { mockImportedComponents } from '../../../test-util/mock-imported-components'; import { mockImportedComponents } from '../../../test-util/mock-imported-components';
import FilterStatus, { $imports } from '../FilterStatus';
function getFilterState() { function getFilterState() {
return { return {
...@@ -53,7 +52,7 @@ describe('FilterStatus', () => { ...@@ -53,7 +52,7 @@ describe('FilterStatus', () => {
$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
$imports.$mock({ $imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread, './hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../store/use-store': { useStoreProxy: () => fakeStore }, '../store/use-store': { useStoreProxy: () => fakeStore },
'../helpers/thread': fakeThreadUtil, '../helpers/thread': fakeThreadUtil,
}); });
......
...@@ -26,7 +26,7 @@ describe('NotebookResultCount', () => { ...@@ -26,7 +26,7 @@ describe('NotebookResultCount', () => {
fakeUseRootThread = sinon.stub().returns({ children: [] }); fakeUseRootThread = sinon.stub().returns({ children: [] });
$imports.$mock({ $imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread, './hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../helpers/thread': { countVisible: fakeCountVisible }, '../helpers/thread': { countVisible: fakeCountVisible },
}); });
}); });
......
...@@ -2,9 +2,7 @@ import { mount } from 'enzyme'; ...@@ -2,9 +2,7 @@ import { mount } from 'enzyme';
import { act } from 'preact/test-utils'; import { act } from 'preact/test-utils';
import { checkAccessibility } from '../../../test-util/accessibility'; import { checkAccessibility } from '../../../test-util/accessibility';
import { mockImportedComponents } from '../../../test-util/mock-imported-components'; import { mockImportedComponents } from '../../../test-util/mock-imported-components';
import { ResultSizeError } from '../../search-client'; import { ResultSizeError } from '../../search-client';
import NotebookView, { $imports } from '../NotebookView'; import NotebookView, { $imports } from '../NotebookView';
...@@ -44,7 +42,7 @@ describe('NotebookView', () => { ...@@ -44,7 +42,7 @@ describe('NotebookView', () => {
$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
$imports.$mock({ $imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread, './hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../store/use-store': { useStoreProxy: () => fakeStore }, '../store/use-store': { useStoreProxy: () => fakeStore },
'scroll-into-view': fakeScrollIntoView, 'scroll-into-view': fakeScrollIntoView,
}); });
......
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import SidebarView from '../SidebarView';
import { $imports } from '../SidebarView';
import { checkAccessibility } from '../../../test-util/accessibility'; import { checkAccessibility } from '../../../test-util/accessibility';
import { mockImportedComponents } from '../../../test-util/mock-imported-components'; import { mockImportedComponents } from '../../../test-util/mock-imported-components';
import SidebarView, { $imports } from '../SidebarView';
describe('SidebarView', () => { describe('SidebarView', () => {
let fakeFrameSync; let fakeFrameSync;
...@@ -70,7 +68,7 @@ describe('SidebarView', () => { ...@@ -70,7 +68,7 @@ describe('SidebarView', () => {
$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
$imports.$mock({ $imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread, './hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../store/use-store': { useStoreProxy: () => fakeStore }, '../store/use-store': { useStoreProxy: () => fakeStore },
'../helpers/tabs': fakeTabsUtil, '../helpers/tabs': fakeTabsUtil,
}); });
......
...@@ -40,7 +40,7 @@ describe('StreamView', () => { ...@@ -40,7 +40,7 @@ describe('StreamView', () => {
$imports.$mock(mockImportedComponents()); $imports.$mock(mockImportedComponents());
$imports.$mock({ $imports.$mock({
'./hooks/use-root-thread': fakeUseRootThread, './hooks/use-root-thread': { useRootThread: fakeUseRootThread },
'../store/use-store': { useStoreProxy: () => fakeStore }, '../store/use-store': { useStoreProxy: () => fakeStore },
'../util/search-filter': fakeSearchFilter, '../util/search-filter': fakeSearchFilter,
}); });
......
...@@ -3,10 +3,9 @@ import { useReducer } from 'preact/hooks'; ...@@ -3,10 +3,9 @@ import { useReducer } from 'preact/hooks';
import { act } from 'preact/test-utils'; import { act } from 'preact/test-utils';
import { Injector } from '../../../shared/injector'; import { Injector } from '../../../shared/injector';
import { createSidebarStore } from '../../store'; import { useRootThread } from '../../components/hooks/use-root-thread';
import { ServiceContext } from '../../service-context'; import { ServiceContext } from '../../service-context';
import useRootThread from '../../components/hooks/use-root-thread'; import { createSidebarStore } from '../../store';
const fixtures = { const fixtures = {
annotations: [ annotations: [
......
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