mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-16 20:11:08 +00:00
- Add dialogActionScopeId to distinguish SftpView and SftpSidePanel dialog actions, preventing cross-instance interference - Refine selectionScope to clear tree selections per-pane instead of using clearAllExcept, avoiding side effects on other SFTP surfaces - Remove selection clearing from tab switch/move/add handlers; clearing now only happens on focus side change and file interaction - Reset keyboard selection and lastSelectedIndex when selections are externally cleared Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
990 B
TypeScript
38 lines
990 B
TypeScript
import type { SftpStateApi } from "../../../application/state/useSftpState";
|
|
import { sftpTreeSelectionStore } from "./useSftpTreeSelectionStore";
|
|
|
|
export interface SftpSelectionTarget {
|
|
side: "left" | "right";
|
|
tabId: string;
|
|
}
|
|
|
|
export const keepOnlyPaneSelections = (
|
|
sftp: SftpStateApi,
|
|
target: SftpSelectionTarget | null,
|
|
) => {
|
|
sftp.clearSelectionsExcept(target);
|
|
const paneIds = [
|
|
...sftp.leftTabs.tabs.map((tab) => tab.id),
|
|
...sftp.rightTabs.tabs.map((tab) => tab.id),
|
|
];
|
|
for (const paneId of paneIds) {
|
|
if (target?.tabId === paneId) continue;
|
|
sftpTreeSelectionStore.clearSelection(paneId);
|
|
}
|
|
};
|
|
|
|
export const keepOnlyActivePaneSelections = (
|
|
sftp: SftpStateApi,
|
|
side: "left" | "right",
|
|
): SftpSelectionTarget | null => {
|
|
const tabId = sftp.getActiveTabId(side);
|
|
if (!tabId) {
|
|
keepOnlyPaneSelections(sftp, null);
|
|
return null;
|
|
}
|
|
|
|
const target = { side, tabId } as const;
|
|
keepOnlyPaneSelections(sftp, target);
|
|
return target;
|
|
};
|