refactor
This commit is contained in:
@@ -14,11 +14,12 @@ export const isPrimaryPointerEvent = (event) => {
|
||||
return type === 'click' || type === 'pointerdown' || type === 'pointerup';
|
||||
};
|
||||
|
||||
export const useEntryPointerHandler = ({
|
||||
export const useEntryPointer = ({
|
||||
resolveDocumentRowKey,
|
||||
resolveFolderRowKey,
|
||||
onSelectDocument,
|
||||
onSelectFolder,
|
||||
onInspectDocument,
|
||||
}) =>
|
||||
useCallback(
|
||||
(entry, event) => {
|
||||
@@ -39,16 +40,20 @@ export const useEntryPointerHandler = ({
|
||||
|
||||
const modifierClick = isPointerModifierEvent(event);
|
||||
const primaryClick = isPrimaryPointerEvent(event);
|
||||
const metadata = { modifierClick, primaryClick, rowKey };
|
||||
|
||||
if (type === 'document') {
|
||||
if (typeof onSelectDocument === 'function') {
|
||||
onSelectDocument(id, event, { modifierClick, primaryClick, rowKey });
|
||||
onSelectDocument(id, event, metadata);
|
||||
}
|
||||
if (!modifierClick && primaryClick && typeof onInspectDocument === 'function') {
|
||||
onInspectDocument(id, metadata);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof onSelectFolder === 'function') {
|
||||
onSelectFolder(id, event, { modifierClick, primaryClick, rowKey });
|
||||
onSelectFolder(id, event, metadata);
|
||||
}
|
||||
},
|
||||
[
|
||||
@@ -56,7 +61,8 @@ export const useEntryPointerHandler = ({
|
||||
resolveFolderRowKey,
|
||||
onSelectDocument,
|
||||
onSelectFolder,
|
||||
onInspectDocument,
|
||||
],
|
||||
);
|
||||
|
||||
export default useEntryPointerHandler;
|
||||
export default useEntryPointer;
|
||||
|
||||
Reference in New Issue
Block a user