Skip to content

Commit

Permalink
fix: prevent update call in case of displaying recurring order active…
Browse files Browse the repository at this point in the history
… status
  • Loading branch information
suschneider committed Sep 4, 2024
1 parent 76fcb27 commit 027c4fd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ <h1>{{ 'account.recurring_order.heading' | translate }}</h1>
><ish-switch
id="{{ recurringOrder.id }}"
[active]="recurringOrder.active"
(switchActiveStatus)="switchActiveStatus($event)"
(switchActiveStatus)="switchActiveStatus($event, recurringOrder.active)"
/></ng-template>
</dd>
</dl>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ export class AccountRecurringOrderPageComponent implements OnInit {
this.recurringOrder$ = this.accountFacade.selectedRecurringOrder$;
}

switchActiveStatus(recurringOrder: { id: string; active: boolean }) {
this.accountFacade.switchActiveStatusRecurringOrder(recurringOrder.id, recurringOrder.active);
switchActiveStatus(recurringOrder: { id: string; active: boolean }, switchStatus: boolean) {
if (recurringOrder.active !== switchStatus) {
this.accountFacade.switchActiveStatusRecurringOrder(recurringOrder.id, recurringOrder.active);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@
<ish-switch
id="{{ recurringOrder.id }}"
[active]="recurringOrder.active"
(switchActiveStatus)="switchActiveStatus($event)"
/></ng-template>
(switchActiveStatus)="switchActiveStatus($event, recurringOrder.active)"
/>
</ng-template>
</td>
</ng-container>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export class RecurringOrderListComponent {

constructor(private accountFacade: AccountFacade) {}

switchActiveStatus(recurringOrder: { id: string; active: boolean }) {
this.accountFacade.switchActiveStatusRecurringOrder(recurringOrder.id, recurringOrder.active);
switchActiveStatus(recurringOrder: { id: string; active: boolean }, switchStatus: boolean) {
if (recurringOrder.active !== switchStatus) {
this.accountFacade.switchActiveStatusRecurringOrder(recurringOrder.id, recurringOrder.active);
}
}
}
8 changes: 4 additions & 4 deletions src/app/shared/components/common/switch/switch.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { FormControl } from '@angular/forms';
*
* @example
* <ish-switch
* id="{{ recurringOrder.id }}"
* [active]="recurringOrder.active"
* (switchActiveStatus)="switchActiveStatus($event)"
* />
* id="{{ recurringOrder.id }}"
* [active]="recurringOrder.active"
* (switchActiveStatus)="switchActiveStatus($event, recurringOrder.active)"
* />
*/
export class SwitchComponent {
@Input({ required: true }) id: string;
Expand Down

0 comments on commit 027c4fd

Please sign in to comment.