- 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.
26 lines
783 B
TypeScript
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 };
|
|
}
|