( profileId: string )
| 1693 | } |
| 1694 | |
| 1695 | async function connectRemoteWorkspaceProfile( |
| 1696 | profileId: string |
| 1697 | ): Promise<{ vault: VaultInfo | null; capabilities: ServerCapabilities }> { |
| 1698 | const cfg = await loadConfig() |
| 1699 | const profile = findRemoteProfileById(cfg.remoteWorkspaceProfiles, profileId) |
| 1700 | if (!profile) { |
| 1701 | throw new Error('That saved remote workspace no longer exists.') |
| 1702 | } |
| 1703 | const authToken = await getRemoteWorkspaceSecret(profile.id) |
| 1704 | const result = await setRemoteWorkspace(profile.baseUrl, authToken, { |
| 1705 | profileId: profile.id, |
| 1706 | vaultPath: profile.vaultPath |
| 1707 | }) |
| 1708 | const connectedAt = Date.now() |
| 1709 | await updateConfig((current) => ({ |
| 1710 | ...current, |
| 1711 | remoteWorkspaceProfileId: profile.id, |
| 1712 | remoteWorkspaceProfiles: current.remoteWorkspaceProfiles.map((entry) => |
| 1713 | entry.id === profile.id ? { ...entry, lastConnectedAt: connectedAt } : entry |
| 1714 | ) |
| 1715 | })) |
| 1716 | currentRemoteWorkspaceProfileId = profile.id |
| 1717 | return result |
| 1718 | } |
| 1719 | |
| 1720 | async function loadCurrentVaultFromConfig(): Promise<VaultInfo | null> { |
| 1721 | const win = currentIpcWindow() ?? mainWindow |
no test coverage detected