feat(api): add listing workspaces

This commit is contained in:
Karol Sójko
2022-10-11 10:57:24 +02:00
parent 15e2c82e65
commit 8376381981
17 changed files with 145 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
import { WorkspaceApiServiceInterface } from '@standardnotes/api'
import { Uuid, WorkspaceType } from '@standardnotes/common'
import { Workspace } from '@standardnotes/models'
import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface'
import { AbstractService } from '../Service/AbstractService'
@@ -13,6 +14,20 @@ export class WorkspaceManager extends AbstractService implements WorkspaceClient
super(internalEventBus)
}
async listWorkspaces(): Promise<{ ownedWorkspaces: Workspace[]; joinedWorkspaces: Workspace[] }> {
try {
const result = await this.workspaceApiService.listWorkspaces()
if (result.data.error !== undefined) {
return { ownedWorkspaces: [], joinedWorkspaces: [] }
}
return result.data
} catch (error) {
return { ownedWorkspaces: [], joinedWorkspaces: [] }
}
}
async acceptInvite(dto: {
inviteUuid: string
userUuid: string