Skip to content

Commit

Permalink
Use useStoreProxy in useRootThread hook
Browse files Browse the repository at this point in the history
Change `useRootThread` hook to use the new API for reading data from the
store.
  • Loading branch information
robertknight committed Dec 10, 2020
1 parent e107483 commit dd3fd83
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/sidebar/components/hooks/test/use-root-thread-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('sidebar/components/hooks/use-root-thread', () => {
fakeThreadAnnotations = sinon.stub().returns('fakeThreadAnnotations');

$imports.$mock({
'../../store/use-store': callback => callback(fakeStore),
'../../store/use-store': { useStoreProxy: () => fakeStore },
'../../util/thread-annotations': fakeThreadAnnotations,
});

Expand Down
13 changes: 7 additions & 6 deletions src/sidebar/components/hooks/use-root-thread.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useMemo } from 'preact/hooks';

import useStore from '../../store/use-store';
import { useStoreProxy } from '../../store/use-store';
import threadAnnotations from '../../util/thread-annotations';

/** @typedef {import('../../util/build-thread').Thread} Thread */
Expand All @@ -12,11 +12,12 @@ import threadAnnotations from '../../util/thread-annotations';
* @return {Thread}
*/
export default function useRootThread() {
const annotations = useStore(store => store.allAnnotations());
const query = useStore(store => store.filterQuery());
const route = useStore(store => store.route());
const selectionState = useStore(store => store.selectionState());
const userFilter = useStore(store => store.userFilter());
const store = useStoreProxy();
const annotations = store.allAnnotations();
const query = store.filterQuery();
const route = store.route();
const selectionState = store.selectionState();
const userFilter = store.userFilter();

const threadState = useMemo(() => {
/** @type {Object.<string,string>} */
Expand Down

0 comments on commit dd3fd83

Please sign in to comment.