Skip to content

Commit

Permalink
fix: make grouping more stable when using skipApplyButtonWhenGrouping
Browse files Browse the repository at this point in the history
  • Loading branch information
punxaphil committed Oct 28, 2024
1 parent f9af53d commit dfb41ff
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/sections/grouping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,18 @@ export class Grouping extends LitElement {
const joinedPlayers = this.joinedPlayers;
const activePlayerId = this.activePlayer.id;
const { unJoin, join, newMainPlayer } = getGroupingChanges(groupingItems, joinedPlayers, activePlayerId);
this.modifiedItems = [];
const selectedPredefinedGroup = this.selectedPredefinedGroup;
this.selectedPredefinedGroup = undefined;

if (join.length > 0) {
await this.mediaControlService.join(newMainPlayer, join);
}
if (unJoin.length > 0) {
await this.mediaControlService.unJoin(unJoin);
}
if (this.selectedPredefinedGroup) {
await this.mediaControlService.setVolumeAndMediaForPredefinedGroup(this.selectedPredefinedGroup);
if (selectedPredefinedGroup) {
await this.mediaControlService.setVolumeAndMediaForPredefinedGroup(selectedPredefinedGroup);
}

if (newMainPlayer !== activePlayerId && !this.config.dontSwitchPlayerWhenGrouping) {
Expand All @@ -195,9 +198,6 @@ export class Grouping extends LitElement {
if (this.config.entityId && unJoin.includes(this.config.entityId) && this.config.dontSwitchPlayerWhenGrouping) {
dispatchActivePlayerId(this.config.entityId, this.config, this);
}

this.modifiedItems = [];
this.selectedPredefinedGroup = undefined;
}

private cancelGrouping() {
Expand Down

0 comments on commit dfb41ff

Please sign in to comment.