Skip to content

Commit

Permalink
Merge branch 'fix/delete_accounts' into 'develop'
Browse files Browse the repository at this point in the history
fix: onWalletSelected insertion logic papers/airgap/airgap-vault#451

See merge request papers/airgap/airgap-vault!458
  • Loading branch information
godenzim committed Jul 13, 2023
2 parents 3bc6678 + 9b3757e commit df6155f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/app/pages/accounts-list/accounts-list.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<ion-item-sliding>
<ng-container *ngIf="deleteView">
<ion-item>
<ion-checkbox slot="start" (click)="onWalletSelected(wallet)"></ion-checkbox>
<ion-checkbox slot="start" (ionChange)="onWalletSelected($event, wallet)"></ion-checkbox>
<airgap-account-item [wallet]="wallet" (click)="goToReceiveAddress(wallet)"></airgap-account-item>
</ion-item>
</ng-container>
Expand Down
16 changes: 9 additions & 7 deletions src/app/pages/accounts-list/accounts-list.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,16 @@ export class AccountsListPage {
})
}

public onWalletSelected(wallet: AirGapWallet): void {
if (this.selectedWallets?.includes(wallet)) {
const index = this.selectedWallets.indexOf(wallet)
if (index > -1) {
this.selectedWallets = this.selectedWallets.splice(index, 1)
}
} else {
public onWalletSelected(event: CustomEvent & { detail: { checked: boolean } }, wallet: AirGapWallet): void {
const index = this.selectedWallets.indexOf(wallet)
const { checked } = event.detail

if (checked && index === -1) {
// if the selected wallet is missing from the array, add it
this.selectedWallets.push(wallet)
} else if (!checked && index !== -1) {
// otherwise when the checkbox is unchecked, remove it
this.selectedWallets.splice(index, 1)
}
}

Expand Down

0 comments on commit df6155f

Please sign in to comment.