-
-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: display shared vault file usage
- Loading branch information
1 parent
5bb749b
commit f038463
Showing
26 changed files
with
127 additions
and
23 deletions.
There are no files selected for viewing
Binary file added
BIN
+67.4 KB
.yarn/cache/@standardnotes-domain-core-npm-1.25.0-51a2ed924b-f99196f620.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/models/src/Domain/Syncable/VaultListing/VaultListingSharingInfo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export type VaultListingSharingInfo = { | ||
sharedVaultUuid: string | ||
ownerUserUuid: string | ||
fileBytesUsed: number | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/responses/src/Domain/SharedVaults/SharedVaultServerHash.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,8 @@ | ||
export interface SharedVaultServerHash { | ||
uuid: string | ||
user_uuid: string | ||
file_upload_bytes_used: number | ||
file_upload_bytes_limit: number | ||
created_at_timestamp: number | ||
updated_at_timestamp: number | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/services/src/Domain/SharedVaults/UseCase/SyncLocalVaultsWithRemoteSharedVaults.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Result, UseCaseInterface } from '@standardnotes/domain-core' | ||
import { SharedVaultServerInterface } from '@standardnotes/api' | ||
import { isErrorResponse } from '@standardnotes/responses' | ||
import { SharedVaultListingInterface, VaultListingInterface, VaultListingMutator } from '@standardnotes/models' | ||
|
||
import { MutatorClientInterface } from '../../Mutator/MutatorClientInterface' | ||
|
||
export class SyncLocalVaultsWithRemoteSharedVaults implements UseCaseInterface<void> { | ||
constructor( | ||
private sharedVaultServer: SharedVaultServerInterface, | ||
private mutator: MutatorClientInterface, | ||
) {} | ||
|
||
async execute(localVaults: VaultListingInterface[]): Promise<Result<void>> { | ||
const remoteVaultsResponse = await this.sharedVaultServer.getSharedVaults() | ||
if (isErrorResponse(remoteVaultsResponse)) { | ||
return Result.fail(remoteVaultsResponse.data.error?.message as string) | ||
} | ||
const remoteVaults = remoteVaultsResponse.data.sharedVaults | ||
console.log('Remote shared vaults', remoteVaults) | ||
|
||
for (const localVault of localVaults) { | ||
if (!localVault.isSharedVaultListing()) { | ||
continue | ||
} | ||
console.log('Processing local vault', localVault.sharing.sharedVaultUuid) | ||
const remoteVault = remoteVaults.find((vault) => vault.uuid === localVault.sharing.sharedVaultUuid) | ||
if (remoteVault) { | ||
console.log('Syncing local vault with remote shared vault', localVault, remoteVault) | ||
await this.mutator.changeItem<VaultListingMutator, SharedVaultListingInterface>(localVault, (mutator) => { | ||
mutator.sharing = { | ||
sharedVaultUuid: remoteVault.uuid, | ||
ownerUserUuid: remoteVault.user_uuid, | ||
fileBytesUsed: remoteVault.file_upload_bytes_used, | ||
} | ||
}) | ||
} | ||
} | ||
|
||
return Result.ok() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.