()
| 82 | } |
| 83 | |
| 84 | export 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 |
no outgoing calls
no test coverage detected