From 2fa1270f0bea737b07d18652e7c9eac120433a3a Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 10 Apr 2019 15:40:40 -0400 Subject: [PATCH] null check optimizations --- src/services/user.service.ts | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/src/services/user.service.ts b/src/services/user.service.ts index 429c6f2169..62ddd0a04a 100644 --- a/src/services/user.service.ts +++ b/src/services/user.service.ts @@ -45,47 +45,37 @@ export class UserService implements UserServiceAbstraction { } async getUserId(): Promise { - if (this.userId != null) { - return this.userId; + if (this.userId == null) { + this.userId = await this.storageService.get(Keys.userId); } - - this.userId = await this.storageService.get(Keys.userId); return this.userId; } async getEmail(): Promise { - if (this.email != null) { - return this.email; + if (this.email == null) { + this.email = await this.storageService.get(Keys.userEmail); } - - this.email = await this.storageService.get(Keys.userEmail); return this.email; } async getSecurityStamp(): Promise { - if (this.stamp != null) { - return this.stamp; + if (this.stamp == null) { + this.stamp = await this.storageService.get(Keys.stamp); } - - this.stamp = await this.storageService.get(Keys.stamp); return this.stamp; } async getKdf(): Promise { - if (this.kdf != null) { - return this.kdf; + if (this.kdf == null) { + this.kdf = await this.storageService.get(Keys.kdf); } - - this.kdf = await this.storageService.get(Keys.kdf); return this.kdf; } async getKdfIterations(): Promise { - if (this.kdfIterations != null) { - return this.kdfIterations; + if (this.kdfIterations == null) { + this.kdfIterations = await this.storageService.get(Keys.kdfIterations); } - - this.kdfIterations = await this.storageService.get(Keys.kdfIterations); return this.kdfIterations; } @@ -117,7 +107,7 @@ export class UserService implements UserServiceAbstraction { } async canAccessPremium(): Promise { - const tokenPremium = await this.tokenService.getPremium(); + const tokenPremium = this.tokenService.getPremium(); if (tokenPremium) { return true; }