( workspaces: Workspace[] | null | undefined, last: LastWorkspace | null | undefined, tabs: WorkspaceTab[] | null | undefined )
| 10 | const same = (w: Workspace, ref: Ref) => !!ref && w.slug === ref.slug && w.owner_username === ref.owner_username; |
| 11 | |
| 12 | export function pickShellWorkspace( |
| 13 | workspaces: Workspace[] | null | undefined, |
| 14 | last: LastWorkspace | null | undefined, |
| 15 | tabs: WorkspaceTab[] | null | undefined |
| 16 | ): Workspace | undefined { |
| 17 | const list = workspaces ?? []; |
| 18 | return ( |
| 19 | list.find((w) => same(w, last)) ?? |
| 20 | (tabs ?? []).map((t) => list.find((w) => same(w, t))).find((w) => !!w) ?? |
| 21 | list[0] |
| 22 | ); |
| 23 | } |
no test coverage detected