feat(sidebar): add conversation sort mode toggle with created-time default

This commit is contained in:
xintaofei
2026-04-22 22:34:23 +08:00
parent 8ef29680d2
commit 5ac9cee2ff
13 changed files with 113 additions and 4 deletions

View File

@@ -2,6 +2,9 @@
const FOLDER_EXPANDED_KEY = "workspace:sidebar-folder-expanded"
const SHOW_COMPLETED_KEY = "workspace:sidebar-show-completed"
const SORT_MODE_KEY = "workspace:sidebar-sort-mode"
export type SidebarSortMode = "created" | "updated"
export function loadFolderExpanded(): Record<number, boolean> {
if (typeof window === "undefined") return {}
@@ -51,3 +54,23 @@ export function saveShowCompleted(value: boolean): void {
/* ignore */
}
}
export function loadSortMode(): SidebarSortMode {
if (typeof window === "undefined") return "created"
try {
const raw = localStorage.getItem(SORT_MODE_KEY)
if (raw === "updated" || raw === "created") return raw
} catch {
/* ignore */
}
return "created"
}
export function saveSortMode(value: SidebarSortMode): void {
if (typeof window === "undefined") return
try {
localStorage.setItem(SORT_MODE_KEY, value)
} catch {
/* ignore */
}
}