mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
dfcdcda189
Adjusts relative import paths across the application to reflect recent changes in the project's directory structure. This primarily affects SFTP state management and modal components. Updates React hook dependency arrays for `useCallback` and `useEffect` to ensure proper memoization and re-execution, addressing `react-hooks/exhaustive-deps` linting rules. Improves type safety for translation function parameters by changing `Record<string, any>` to `Record<string, unknown>`. Adds the `ls` command to the allowed commands for the Claude AI assistant in local settings.
28 lines
875 B
TypeScript
28 lines
875 B
TypeScript
import { useEffect } from "react";
|
|
import { netcattyBridge } from "../../../infrastructure/services/netcattyBridge";
|
|
import type { FileWatchErrorEvent, FileWatchSyncedEvent, SftpStateOptions } from "./types";
|
|
|
|
export const useSftpFileWatch = (options?: SftpStateOptions) => {
|
|
useEffect(() => {
|
|
const bridge = netcattyBridge.get();
|
|
if (!bridge?.onFileWatchSynced || !bridge?.onFileWatchError) return;
|
|
|
|
const unsubscribeSynced = bridge.onFileWatchSynced((payload: FileWatchSyncedEvent) => {
|
|
options?.onFileWatchSynced?.(payload);
|
|
});
|
|
|
|
const unsubscribeError = bridge.onFileWatchError((payload: FileWatchErrorEvent) => {
|
|
options?.onFileWatchError?.(payload);
|
|
});
|
|
|
|
return () => {
|
|
try {
|
|
unsubscribeSynced?.();
|
|
unsubscribeError?.();
|
|
} catch {
|
|
// ignore cleanup errors
|
|
}
|
|
};
|
|
}, [options]);
|
|
};
|