Skip to content

Commit

Permalink
feat(ui): add ability to customize wallets list order
Browse files Browse the repository at this point in the history
  • Loading branch information
thekiba committed Nov 16, 2024
1 parent 8615ff8 commit 8890b02
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/ui/src/app/utils/wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ export function applyWalletsListConfiguration(
);
}

if (configuration.customOrder?.length) {
const uniqueOrderedNames = [...new Set(configuration.customOrder)];

const customOrderedWallets = uniqueOrderedNames
.map(orderedName => walletsList.find(wallet => wallet.appName === orderedName))
.filter((wallet): wallet is WalletInfo => wallet !== undefined);

const remainingWallets = walletsList.filter(
wallet => !uniqueOrderedNames.includes(wallet.appName)
);

walletsList = [...customOrderedWallets, ...remainingWallets];
}

return walletsList;
}

Expand Down
6 changes: 6 additions & 0 deletions packages/ui/src/models/wallets-list-configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,10 @@ export type WalletsListConfiguration = {
* Allows to include extra wallets to the wallets list in the modal.
*/
includeWallets?: UIWallet[];

/**
* List of wallet IDs to be displayed first in the specified order.
* Other wallets will be shown below in their original order.
*/
customOrder?: string[];
};

0 comments on commit 8890b02

Please sign in to comment.