-
-
Notifications
You must be signed in to change notification settings - Fork 393
/
DeleteSharedVault.ts
27 lines (22 loc) · 1017 Bytes
/
DeleteSharedVault.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { ClientDisplayableError, isErrorResponse } from '@standardnotes/responses'
import { SharedVaultServerInterface } from '@standardnotes/api'
import { SharedVaultListingInterface } from '@standardnotes/models'
import { SyncServiceInterface } from '../../Sync/SyncServiceInterface'
import { DeleteVault } from '../../Vault/UseCase/DeleteVault'
export class DeleteSharedVault {
constructor(
private sharedVaultServer: SharedVaultServerInterface,
private sync: SyncServiceInterface,
private deleteVault: DeleteVault,
) {}
async execute(params: { sharedVault: SharedVaultListingInterface }): Promise<ClientDisplayableError | void> {
const response = await this.sharedVaultServer.deleteSharedVault({
sharedVaultUuid: params.sharedVault.sharing.sharedVaultUuid,
})
if (isErrorResponse(response)) {
return ClientDisplayableError.FromString(`Failed to delete vault ${response}`)
}
await this.deleteVault.execute(params.sharedVault)
await this.sync.sync()
}
}