mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-10-09 15:58:34 +00:00
f7483f0593
* fix(#3565): automated AI fix * fix: address Codex review on PR #3567 * fix: address Codex review on PR #3567 * fix: address Codex review on PR #3567 * fix: address Codex review on PR #3567 * fix(scripts): observe stacked sentinel again after returning to library * fix(scripts): reuse shared persisted string hook for cross-window view changes --------- Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com> Co-authored-by: 陈大猫 <16399091+binaricat@users.noreply.github.com>
20 lines
865 B
TypeScript
20 lines
865 B
TypeScript
import { STORAGE_KEY_SCRIPTS_SIDE_PANEL_VIEW } from "../../infrastructure/config/storageKeys";
|
|
import { useStoredString } from "./useStoredString";
|
|
|
|
/** View modes for the scripts side panel library:
|
|
* 'list' (one snippet per row, tree of packages) and 'stacked' (compact
|
|
* wrap-around chips). */
|
|
export type ScriptsViewMode = "list" | "stacked";
|
|
|
|
export const SCRIPTS_VIEW_MODE_STORAGE_KEY = STORAGE_KEY_SCRIPTS_SIDE_PANEL_VIEW;
|
|
|
|
/** Pure resolver so callers and tests share one validation rule. */
|
|
export const parseScriptsViewMode = (value: string | null): ScriptsViewMode =>
|
|
value === "stacked" ? "stacked" : "list";
|
|
|
|
const isScriptsViewMode = (value: string | null): value is ScriptsViewMode =>
|
|
value === "list" || value === "stacked";
|
|
|
|
export const useScriptsViewMode = () =>
|
|
useStoredString(SCRIPTS_VIEW_MODE_STORAGE_KEY, "list", isScriptsViewMode);
|