CR Updates

This commit is contained in:
igoroctaviano committed 2020-06-29 13:58:36 -03:00
1 parent c8052e0e0a
commit f96c1f6648
4 files changed
+44 -56

No files matched your search

+1 -2
View File
@@ -1,5 +1,4 @@
import useDebounce from './useDebounce.js';
import useQuery from './useQuery.js';
import useHotkeys from './useHotkeys.js';
export { useDebounce, useQuery, useHotkeys };
export { useDebounce, useQuery };
-31
View File
@@ -1,31 +0,0 @@
import { useEffect, useState } from 'react';
/**
* @param {Object} manager HotkeysManager instance
* @param {Object} hotkeys hotkey bindings
* @param {Object} defaultHotkeys default hotkey bindings
*/
const useHotkeys = (manager, hotkeys, defaultHotkeys) => {
const [isLoaded, setIsLoaded] = useState(false);
useEffect(() => {
if (!hotkeys) {
console.warn('[hotkeys] No bindings defined for hotkeys hook!');
return;
}
console.debug('[hotkeys] Setting up hotkeys...');
manager.setDefaultHotKeys(defaultHotkeys || hotkeys);
manager.setHotkeys(hotkeys);
setIsLoaded(true);
return () => {
console.debug('[hotkeys] Removing hotkeys...');
manager.destroy();
};
}, [manager, hotkeys, defaultHotkeys]);
return isLoaded;
}
export default useHotkeys;
+19 -5
View File
@@ -5,7 +5,7 @@ import PropTypes from 'prop-types';
import { DicomMetadataStore } from '@ohif/core';
import { DragAndDropProvider, ImageViewerProvider } from '@ohif/ui';
//
import { useQuery, useHotkeys } from '@hooks';
import { useQuery } from '@hooks';
import ViewportGrid from '@components/ViewportGrid';
import Compose from './Compose';
@@ -17,7 +17,6 @@ export default function ModeRoute({
servicesManager,
hotkeysManager
}) {
const isHotkeysLoaded = useHotkeys(hotkeysManager, mode.hotkeys);
// Parse route params/querystring
const query = useQuery();
const queryStudyInstanceUIDs = query.get('StudyInstanceUIDs');
@@ -28,7 +27,7 @@ export default function ModeRoute({
? StudyInstanceUIDs
: [StudyInstanceUIDs];
const { extensions, sopClassHandlers } = mode;
const { extensions, sopClassHandlers, hotkeys } = mode;
if (dataSourceName === undefined) {
dataSourceName = extensionManager.defaultDataSourceName;
@@ -76,6 +75,22 @@ export default function ModeRoute({
return ViewportGrid({ ...props, dataSource });
}
useEffect(() => {
if (!hotkeys) {
console.warn('[hotkeys] No bindings defined for hotkeys hook!');
return;
}
console.debug('[hotkeys] Setting up hotkeys...');
hotkeysManager.setDefaultHotKeys(hotkeys);
hotkeysManager.setHotkeys(hotkeys);
return () => {
console.debug('[hotkeys] Removing hotkeys...');
hotkeysManager.destroy();
};
}, []);
useEffect(() => {
route.init({ servicesManager, extensionManager });
}, [
@@ -85,8 +100,7 @@ export default function ModeRoute({
route,
servicesManager,
extensionManager,
hotkeysManager,
isHotkeysLoaded
hotkeysManager
]);
// This queries for series, but... What does it do with them?