Skip to content

Commit 3a3a470

Browse files
Merge pull request #642 from softwaremagico/640-adding-multiples-custom-fights-unselect-the-group-and-force-the-user-to-select-a-new-fight-each-time
Fixed group is unselected after adding a new fight.
2 parents 8aa86e2 + 4ec7117 commit 3a3a470

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

frontend/src/app/views/fight-list/fight-list.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ export class FightListComponent extends RbacBasedComponent implements OnInit, On
236236
//Corrected selected items
237237
if (this.selectedFight) {
238238
for (const _group of this.groups) {
239-
if (_group.fights.indexOf(this.selectedFight)) {
239+
if (_group.fights.indexOf(this.selectedFight) >= 0) {
240240
selectedFightIndex = _group.fights.indexOf(this.selectedFight);
241241
}
242242
}
@@ -247,10 +247,10 @@ export class FightListComponent extends RbacBasedComponent implements OnInit, On
247247
this.groups.splice(groupIndex, 1, group);
248248
this.selectedGroup = this.groups[groupIndex];
249249
this.resetFilter();
250-
if (this.selectedGroup && this.selectedFight && selectedFightIndex) {
250+
if (this.selectedGroup && this.selectedFight && selectedFightIndex !== undefined) {
251251
this.selectFight(this.filteredFights.get(this.selectedGroup.id!)![selectedFightIndex]);
252252
} else {
253-
this.selectFight(undefined);
253+
this.selectFight(this.selectedFight);
254254
}
255255
if (this.selectedFight && selectedDuelIndex && this.selectedFight?.duels[selectedDuelIndex]) {
256256
this.selectDuel(this.selectedFight.duels[selectedDuelIndex]);
@@ -595,7 +595,7 @@ export class FightListComponent extends RbacBasedComponent implements OnInit, On
595595
selectFight(fight: Fight | undefined): void {
596596
this.selectedFight = fight;
597597
if (fight) {
598-
this.selectedGroup = this.groups.find((group: Group): boolean => group.fights.indexOf(fight) >= 0)!;
598+
this.selectedGroup = this.groups.find(group => group.fights.indexOf(fight) >= 0);
599599
} else {
600600
this.selectedGroup = undefined;
601601
}

0 commit comments

Comments
 (0)