MCPcopy Create free account
hub / github.com/ZenNotes/zennotes / connectRemoteWorkspaceProfile

Function connectRemoteWorkspaceProfile

apps/desktop/src/main/index.ts:1695–1718  ·  view source on GitHub ↗
(
  profileId: string
)

Source from the content-addressed store, hash-verified

1693}
1694
1695async 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
1720async function loadCurrentVaultFromConfig(): Promise<VaultInfo | null> {
1721 const win = currentIpcWindow() ?? mainWindow

Callers 4

registerIpcFunction · 0.70
switchVaultFunction · 0.50
SettingsModalFunction · 0.50
SidebarFunction · 0.50

Calls 5

loadConfigFunction · 0.90
getRemoteWorkspaceSecretFunction · 0.90
updateConfigFunction · 0.90
findRemoteProfileByIdFunction · 0.85
setRemoteWorkspaceFunction · 0.85

Tested by

no test coverage detected