chore: refetch subscription when prefs menu opens (#2360)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Role } from '@standardnotes/security'
|
||||
import { Role } from '@standardnotes/responses'
|
||||
|
||||
export type MetaReceivedData = {
|
||||
userUuid: string
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
isNote,
|
||||
NoteContent,
|
||||
} from '@standardnotes/models'
|
||||
import { ClientDisplayableError } from '@standardnotes/responses'
|
||||
import { ClientDisplayableError, ValetTokenOperation } from '@standardnotes/responses'
|
||||
import {
|
||||
FilesApiInterface,
|
||||
FileBackupMetadataFile,
|
||||
@@ -520,7 +520,7 @@ export class FilesBackupService extends AbstractService implements BackupService
|
||||
},
|
||||
})
|
||||
|
||||
const token = await this.api.createUserFileValetToken(file.remoteIdentifier, 'read')
|
||||
const token = await this.api.createUserFileValetToken(file.remoteIdentifier, ValetTokenOperation.Read)
|
||||
|
||||
if (token instanceof ClientDisplayableError) {
|
||||
this.status.removeMessage(messageId)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -13,8 +13,12 @@ import { InternalEventBusInterface } from '../Internal/InternalEventBusInterface
|
||||
import { AbstractService } from '../Service/AbstractService'
|
||||
import { SubscriptionManagerInterface } from './SubscriptionManagerInterface'
|
||||
import { AppleIAPReceipt } from './AppleIAPReceipt'
|
||||
import { AvailableSubscriptions, getErrorFromErrorResponse, isErrorResponse } from '@standardnotes/responses'
|
||||
import { Subscription } from '@standardnotes/security'
|
||||
import {
|
||||
AvailableSubscriptions,
|
||||
getErrorFromErrorResponse,
|
||||
isErrorResponse,
|
||||
Subscription,
|
||||
} from '@standardnotes/responses'
|
||||
import { SubscriptionManagerEvent } from './SubscriptionManagerEvent'
|
||||
|
||||
export class SubscriptionManager
|
||||
@@ -170,7 +174,7 @@ export class SubscriptionManager
|
||||
}
|
||||
}
|
||||
|
||||
private async fetchOnlineSubscription(): Promise<void> {
|
||||
public async fetchOnlineSubscription(): Promise<void> {
|
||||
if (!this.sessions.isSignedIn()) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { ApplicationServiceInterface } from './../Service/ApplicationServiceInterface'
|
||||
import { Invitation } from '@standardnotes/models'
|
||||
import { AppleIAPReceipt } from './AppleIAPReceipt'
|
||||
import { AvailableSubscriptions } from '@standardnotes/responses'
|
||||
import { Subscription } from '@standardnotes/security'
|
||||
import { AvailableSubscriptions, Subscription } from '@standardnotes/responses'
|
||||
import { SubscriptionManagerEvent } from './SubscriptionManagerEvent'
|
||||
|
||||
export interface SubscriptionManagerInterface extends ApplicationServiceInterface<SubscriptionManagerEvent, unknown> {
|
||||
@@ -15,6 +14,7 @@ export interface SubscriptionManagerInterface extends ApplicationServiceInterfac
|
||||
get isUserSubscriptionExpired(): boolean
|
||||
get isUserSubscriptionCanceled(): boolean
|
||||
|
||||
fetchOnlineSubscription(): Promise<void>
|
||||
listSubscriptionInvitations(): Promise<Invitation[]>
|
||||
inviteToSubscription(inviteeEmail: string): Promise<boolean>
|
||||
cancelInvitation(inviteUuid: string): Promise<boolean>
|
||||
|
||||
Reference in New Issue
Block a user