[PS-153] upgrade premium on refresh (#813)

* sync premium state on refresh

* lint fix
This commit is contained in:
Gbubemi Smith 2022-05-27 19:08:22 +01:00 committed by GitHub
parent 1ea2824c24
commit 0d658ba26d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View File

@ -58,6 +58,7 @@ export abstract class StateService<T extends Account = Account> {
getBiometricUnlock: (options?: StorageOptions) => Promise<boolean>; getBiometricUnlock: (options?: StorageOptions) => Promise<boolean>;
setBiometricUnlock: (value: boolean, options?: StorageOptions) => Promise<void>; setBiometricUnlock: (value: boolean, options?: StorageOptions) => Promise<void>;
getCanAccessPremium: (options?: StorageOptions) => Promise<boolean>; getCanAccessPremium: (options?: StorageOptions) => Promise<boolean>;
setCanAccessPremium: (value: boolean, options?: StorageOptions) => Promise<void>;
getClearClipboard: (options?: StorageOptions) => Promise<number>; getClearClipboard: (options?: StorageOptions) => Promise<number>;
setClearClipboard: (value: number, options?: StorageOptions) => Promise<void>; setClearClipboard: (value: number, options?: StorageOptions) => Promise<void>;
getCollapsedGroupings: (options?: StorageOptions) => Promise<string[]>; getCollapsedGroupings: (options?: StorageOptions) => Promise<string[]>;

View File

@ -359,6 +359,17 @@ export class StateService<
return false; return false;
} }
async setCanAccessPremium(value: boolean, options?: StorageOptions): Promise<void> {
const account = await this.getAccount(
this.reconcileOptions(options, await this.defaultOnDiskOptions())
);
account.profile.hasPremiumPersonally = value;
await this.saveAccount(
account,
this.reconcileOptions(options, await this.defaultOnDiskOptions())
);
}
async getClearClipboard(options?: StorageOptions): Promise<number> { async getClearClipboard(options?: StorageOptions): Promise<number> {
return ( return (
( (

View File

@ -304,6 +304,7 @@ export class SyncService implements SyncServiceAbstraction {
await this.cryptoService.setOrgKeys(response.organizations, response.providerOrganizations); await this.cryptoService.setOrgKeys(response.organizations, response.providerOrganizations);
await this.stateService.setSecurityStamp(response.securityStamp); await this.stateService.setSecurityStamp(response.securityStamp);
await this.stateService.setEmailVerified(response.emailVerified); await this.stateService.setEmailVerified(response.emailVerified);
await this.stateService.setCanAccessPremium(response.premium);
await this.stateService.setForcePasswordReset(response.forcePasswordReset); await this.stateService.setForcePasswordReset(response.forcePasswordReset);
await this.keyConnectorService.setUsesKeyConnector(response.usesKeyConnector); await this.keyConnectorService.setUsesKeyConnector(response.usesKeyConnector);