userid null check

This commit is contained in:
Kyle Spearrin 2018-02-15 13:39:23 -05:00
parent 4412708ecb
commit 7b3bbd9245
1 changed files with 8 additions and 0 deletions

View File

@ -35,6 +35,10 @@ export class SyncService implements SyncServiceAbstraction {
async getLastSync(): Promise<Date> { async getLastSync(): Promise<Date> {
const userId = await this.userService.getUserId(); const userId = await this.userService.getUserId();
if (userId == null) {
return null;
}
const lastSync = await this.storageService.get<any>(Keys.lastSyncPrefix + userId); const lastSync = await this.storageService.get<any>(Keys.lastSyncPrefix + userId);
if (lastSync) { if (lastSync) {
return new Date(lastSync); return new Date(lastSync);
@ -45,6 +49,10 @@ export class SyncService implements SyncServiceAbstraction {
async setLastSync(date: Date): Promise<any> { async setLastSync(date: Date): Promise<any> {
const userId = await this.userService.getUserId(); const userId = await this.userService.getUserId();
if (userId == null) {
return;
}
await this.storageService.save(Keys.lastSyncPrefix + userId, date.toJSON()); await this.storageService.save(Keys.lastSyncPrefix + userId, date.toJSON());
} }