MCPcopy
hub / github.com/msgbyte/tianji / useCurrentWorkspaceSafe

Function useCurrentWorkspaceSafe

src/client/store/user.ts:84–113  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

82}
83
84export function useCurrentWorkspaceSafe() {
85 const currentWorkspace = useUserStore((state) => {
86 if (!state.info) {
87 return null;
88 }
89
90 const currentWorkspaceId = state.info.currentWorkspaceId;
91 if (!currentWorkspaceId) {
92 return null;
93 }
94
95 const currentWorkspace = state.info?.workspaces.find(
96 (w) => w.workspace.id === currentWorkspaceId
97 );
98
99 if (!currentWorkspace) {
100 return null;
101 }
102
103 return {
104 id: currentWorkspace.workspace.id,
105 name: currentWorkspace.workspace.name,
106 role: currentWorkspace.role,
107 settings: currentWorkspace.workspace.settings,
108 paused: currentWorkspace.workspace.paused,
109 };
110 });
111
112 return currentWorkspace;
113}
114
115/**
116 * Direct return current workspace info

Callers 4

Header.tsxFile · 0.90
PageComponentFunction · 0.90
useCurrentWorkspaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected