Skip to content

Commit

Permalink
Merge pull request #31 from appodeal/feature/amsa-35_amsa-36_amsa-37
Browse files Browse the repository at this point in the history
[AMSA-35] [AMSA-36] [AMSA-37]
  • Loading branch information
NaLLiFFuNT authored Apr 17, 2019
2 parents f63d440 + 67e33fb commit 47065e1
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 107 deletions.
82 changes: 22 additions & 60 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 15 additions & 4 deletions src/core/appdeal-api/appodeal-api.factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ export class AppodealApi {
throw err;
});
if (account) {
this.destroyApi(account.id);
this.saveApi(api, account);
sessionInfo.save(account.id);
} else {
api.destroy();
}
return account;
}
Expand All @@ -63,10 +66,7 @@ export class AppodealApi {
error.isHandled = true;
}
});
api.destroy();
this.APIs.delete(accountId);
this.errorSubscriptions.get(accountId).unsubscribe();
this.errorSubscriptions.delete(accountId);
this.destroyApi(accountId);
await AppodealSessions.remove(accountId);
}

Expand All @@ -81,6 +81,17 @@ export class AppodealApi {
));
}

private destroyApi (accountId: string) {
if (this.APIs.has(accountId)) {
this.APIs.get(accountId).destroy();
this.APIs.delete(accountId);
}
if (this.errorSubscriptions.has(accountId)) {
this.errorSubscriptions.get(accountId).unsubscribe();
this.errorSubscriptions.delete(accountId);
}
}

private saveApi (api: AppodealApiService, account: UserAccount) {
api.init(account.id);
this.APIs.set(account.id, api);
Expand Down
Loading

0 comments on commit 47065e1

Please sign in to comment.