Skip to content

Commit

Permalink
optimize filter for wallet list
Browse files Browse the repository at this point in the history
Signed-off-by: Mirko Mollik <mirkomollik@gmail.com>
  • Loading branch information
cre8 committed Oct 28, 2024
1 parent eaa877f commit e7fc4e0
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion viewer/src/app/wallets/wallets-list/wallets-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,28 @@ export class WalletsListComponent implements OnInit, AfterViewInit {
.subscribe(async (res: WalletFilter) => {
this.router.navigate([], {
relativeTo: this.route,
fragment: JSON.stringify(res),
fragment: this.reduceObject(res ?? {}),
replaceUrl: false,
});
this.filter = res;
this.loadWallets();
});
}

/**
* Removes all elements from the object that are undefined
* @param object
*/
private reduceObject(object: any) {
Object.keys(object).forEach((key) => {
if (object[key] === null) {
delete object[key];
}
});
if (Object.keys(object).length === 0) return undefined;
return JSON.stringify(object);
}

/**
* Load the filtered wallets
*/
Expand Down

0 comments on commit e7fc4e0

Please sign in to comment.