chore: refetch subscription when prefs menu opens (#2360)

This commit is contained in:
Mo
2023-07-17 09:04:22 -05:00
committed by GitHub
parent a56e1f5398
commit 7fb33c400c
31 changed files with 113 additions and 66 deletions

View File

@@ -1,9 +1,10 @@
import { MutatorClientInterface } from './../Mutator/MutatorClientInterface'
import {
ClientDisplayableError,
ValetTokenOperation,
isClientDisplayableError,
isErrorResponse,
SharedVaultMoveType,
ValetTokenOperation,
} from '@standardnotes/responses'
import {
FileItem,
@@ -47,12 +48,7 @@ import { AbstractService } from '../Service/AbstractService'
import { SyncServiceInterface } from '../Sync/SyncServiceInterface'
import { DecryptItemsKeyWithUserFallback } from '../Encryption/Functions'
import { log, LoggingDomain } from '../Logging'
import {
SharedVaultMoveType,
SharedVaultServer,
SharedVaultServerInterface,
HttpServiceInterface,
} from '@standardnotes/api'
import { SharedVaultServer, SharedVaultServerInterface, HttpServiceInterface } from '@standardnotes/api'
import { ContentType } from '@standardnotes/domain-core'
const OneHundredMb = 100 * 1_000_000
@@ -111,7 +107,7 @@ export class FileService extends AbstractService implements FilesClientInterface
moveOperationType?: SharedVaultMoveType
sharedVaultToSharedVaultMoveTargetUuid?: string
}): Promise<string | ClientDisplayableError> {
if (params.operation !== 'write' && !params.fileUuidRequiredForExistingFiles) {
if (params.operation !== ValetTokenOperation.Write && !params.fileUuidRequiredForExistingFiles) {
throw new Error('File UUID is required for for non-write operations')
}
@@ -139,7 +135,7 @@ export class FileService extends AbstractService implements FilesClientInterface
const valetTokenResult = await this.createSharedVaultValetToken({
sharedVaultUuid: file.shared_vault_uuid ? file.shared_vault_uuid : sharedVault.sharing.sharedVaultUuid,
remoteIdentifier: file.remoteIdentifier,
operation: 'move',
operation: ValetTokenOperation.Move,
fileUuidRequiredForExistingFiles: file.uuid,
moveOperationType: file.shared_vault_uuid ? 'shared-vault-to-shared-vault' : 'user-to-shared-vault',
sharedVaultToSharedVaultMoveTargetUuid: file.shared_vault_uuid ? sharedVault.sharing.sharedVaultUuid : undefined,
@@ -164,7 +160,7 @@ export class FileService extends AbstractService implements FilesClientInterface
const valetTokenResult = await this.createSharedVaultValetToken({
sharedVaultUuid: file.shared_vault_uuid,
remoteIdentifier: file.remoteIdentifier,
operation: 'move',
operation: ValetTokenOperation.Move,
fileUuidRequiredForExistingFiles: file.uuid,
moveOperationType: 'shared-vault-to-user',
})
@@ -190,10 +186,10 @@ export class FileService extends AbstractService implements FilesClientInterface
? await this.createSharedVaultValetToken({
sharedVaultUuid: vault.sharing.sharedVaultUuid,
remoteIdentifier,
operation: 'write',
operation: ValetTokenOperation.Write,
unencryptedFileSizeForUpload: sizeInBytes,
})
: await this.createUserValetToken(remoteIdentifier, 'write', sizeInBytes)
: await this.createUserValetToken(remoteIdentifier, ValetTokenOperation.Write, sizeInBytes)
if (valetTokenResult instanceof ClientDisplayableError) {
return valetTokenResult
@@ -342,10 +338,10 @@ export class FileService extends AbstractService implements FilesClientInterface
? await this.createSharedVaultValetToken({
sharedVaultUuid: file.shared_vault_uuid,
remoteIdentifier: file.remoteIdentifier,
operation: 'read',
operation: ValetTokenOperation.Read,
fileUuidRequiredForExistingFiles: file.uuid,
})
: await this.createUserValetToken(file.remoteIdentifier, 'read')
: await this.createUserValetToken(file.remoteIdentifier, ValetTokenOperation.Read)
if (tokenResult instanceof ClientDisplayableError) {
return tokenResult
@@ -375,10 +371,10 @@ export class FileService extends AbstractService implements FilesClientInterface
? await this.createSharedVaultValetToken({
sharedVaultUuid: file.shared_vault_uuid,
remoteIdentifier: file.remoteIdentifier,
operation: 'delete',
operation: ValetTokenOperation.Delete,
fileUuidRequiredForExistingFiles: file.uuid,
})
: await this.createUserValetToken(file.remoteIdentifier, 'delete')
: await this.createUserValetToken(file.remoteIdentifier, ValetTokenOperation.Delete)
if (tokenResult instanceof ClientDisplayableError) {
return tokenResult