feat(electron): mouse middle click to close tab (#7759)

fix AF-1200
This commit is contained in:
pengx17
2024-08-07 05:19:45 +00:00
parent 352ceca94b
commit b5e543c406
11 changed files with 66 additions and 66 deletions
@@ -1,4 +1,4 @@
import React from 'react';
import React, { type DependencyList } from 'react';
export type AsyncErrorHandler = (error: Error) => void;
@@ -17,7 +17,7 @@ export const AsyncCallbackContext = React.createContext<AsyncErrorHandler>(
*/
export function useAsyncCallback<T extends any[]>(
callback: (...args: T) => Promise<void>,
deps: any[]
deps: DependencyList
): (...args: T) => void {
const handleAsyncError = React.useContext(AsyncCallbackContext);
return React.useCallback(
@@ -0,0 +1,17 @@
import { type DependencyList, type SyntheticEvent } from 'react';
import { useAsyncCallback } from './affine-async-hooks';
export const useCatchEventCallback = <E extends SyntheticEvent>(
cb: (e: E) => void | Promise<void>,
deps: DependencyList
) => {
return useAsyncCallback(
async (e: E) => {
e.stopPropagation();
await cb(e);
},
// eslint-disable-next-line react-hooks/exhaustive-deps
deps
);
};