Skip to content

Commit

Permalink
Merge pull request #838 from viktorgullmark/bug/old-leagues-not-cleared
Browse files Browse the repository at this point in the history
Bug/old leagues not cleared
  • Loading branch information
viktorgullmark authored Aug 21, 2022
2 parents 4a63412 + 8cfe4da commit 3ce1d7b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 16 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.2.0] - NOT RELEASED
#### Fixed
- Fixed a bug where rate limits could sometimes occur from fetching obsolete leagues

## [1.1.8] - 2022-02-20
#### Added
- Added support for choosing installation path when installing the application
Expand Down
13 changes: 5 additions & 8 deletions ExilenceNextApp/src/store/domains/account.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AxiosError } from 'axios';
import { action, computed, makeObservable, observable, runInAction } from 'mobx';
import { action, computed, makeObservable, observable, runInAction, toJS } from 'mobx';
import { persist } from 'mobx-persist';
import { fromStream } from 'mobx-utils';
import { of, Subject, throwError, timer } from 'rxjs';
Expand Down Expand Up @@ -269,19 +269,16 @@ export class Account implements IAccount {

@action
updateAccountLeagues(characters: ICharacter[]) {
this.accountLeagues = [];
rootStore.leagueStore.leagues.forEach((l) => {
let accLeague = this.accountLeagues.find((al) => al.leagueId === l.id);
const leagueCharacters = characters.filter((c) => c.league === l.id);

if (accLeague) {
accLeague = new AccountLeague(l.id);
if (leagueCharacters) {
accLeague.updateCharacters(leagueCharacters);
}

if (!accLeague && leagueCharacters) {
accLeague = new AccountLeague(l.id);
accLeague.updateCharacters(leagueCharacters);
this.accountLeagues.push(accLeague);
}
this.accountLeagues.push(accLeague);
});
}

Expand Down
11 changes: 3 additions & 8 deletions ExilenceNextApp/src/store/leagueStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,9 @@ export class LeagueStore {

@action
updateLeagues(leagues: ILeague[]) {
const newLeagues = leagues.filter(
(l) => this.leagues.find((el) => el.id === l.id) === undefined
);
this.leagues = this.leagues.concat(
newLeagues.map((league) => {
return new League(league);
})
);
this.leagues = leagues.map((l) => {
return new League(l);
});
}

@action
Expand Down

0 comments on commit 3ce1d7b

Please sign in to comment.