Files
nyaterm/src/lib/quickCommandSettings.ts
T
Kang d83419d58b feat(quickCommands): implement drag-and-drop functionality for quick command categories (#370)
- Added support for moving quick command categories within the UI, allowing users to reorder categories through drag-and-drop.
- Introduced new interfaces and utility functions to manage category movement and sorting.
- Enhanced the QuickCommands component to handle new category creation and validation.
- Updated related tests to ensure correct behavior of the new features.
2026-08-12 16:33:40 +08:00

26 lines
783 B
TypeScript

import type { AppSettings, QuickCommandSortMode, UiConfig } from "@/types/global";
export function normalizeQuickCommandSortMode(
mode: unknown,
): QuickCommandSortMode {
return mode === "name" || mode === "useCount" || mode === "custom"
? mode
: "created";
}
export function normalizeQuickCommandUiConfig(ui: UiConfig): UiConfig {
const quickCommandSortMode = normalizeQuickCommandSortMode(
ui.quick_cmd_sort_mode,
);
return quickCommandSortMode === ui.quick_cmd_sort_mode
? ui
: { ...ui, quick_cmd_sort_mode: quickCommandSortMode };
}
export function normalizeQuickCommandAppSettings(
settings: AppSettings,
): AppSettings {
const ui = normalizeQuickCommandUiConfig(settings.ui);
return ui === settings.ui ? settings : { ...settings, ui };
}