Group and clear workspace status in the sidebar (#1317)
* Add status grouping to the workspace sidebar * Mark workspaces as read from the sidebar * Clean package builds before release checks * Fix sidebar status follow-up checks
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { create } from "zustand";
|
||||
import { createJSONStorage, persist } from "zustand/middleware";
|
||||
|
||||
export type SidebarGroupMode = "project" | "status";
|
||||
|
||||
interface SidebarViewStoreState {
|
||||
groupModeByServerId: Record<string, SidebarGroupMode>;
|
||||
getGroupMode: (serverId: string) => SidebarGroupMode;
|
||||
setGroupMode: (serverId: string, mode: SidebarGroupMode) => void;
|
||||
}
|
||||
|
||||
export const useSidebarViewStore = create<SidebarViewStoreState>()(
|
||||
persist(
|
||||
(set, get) => ({
|
||||
groupModeByServerId: {},
|
||||
getGroupMode: (serverId) => {
|
||||
const key = serverId.trim();
|
||||
if (!key) return "project";
|
||||
return get().groupModeByServerId[key] ?? "project";
|
||||
},
|
||||
setGroupMode: (serverId, mode) => {
|
||||
const key = serverId.trim();
|
||||
if (!key) return;
|
||||
set((state) => ({
|
||||
groupModeByServerId: {
|
||||
...state.groupModeByServerId,
|
||||
[key]: mode,
|
||||
},
|
||||
}));
|
||||
},
|
||||
}),
|
||||
{
|
||||
name: "sidebar-group-mode",
|
||||
storage: createJSONStorage(() => AsyncStorage),
|
||||
partialize: (state) => ({
|
||||
groupModeByServerId: state.groupModeByServerId,
|
||||
}),
|
||||
},
|
||||
),
|
||||
);
|
||||
Reference in New Issue
Block a user