Skip to content

Commit 98caa3a

Browse files
🎨 [Frontend] Enh: Preferred Wallet (#7978)
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 4546aa7 commit 98caa3a

File tree

1 file changed

+11
-3
lines changed
  • services/static-webserver/client/source/class/osparc/store

1 file changed

+11
-3
lines changed

services/static-webserver/client/source/class/osparc/store/Store.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,18 @@ qx.Class.define("osparc.store.Store", {
389389
const preferenceWalletId = preferenceSettings.getPreferredWalletId();
390390
if (
391391
(preferenceWalletId === null || osparc.desktop.credits.Utils.getWallet(preferenceWalletId) === null) &&
392-
wallets.length === 1
392+
wallets.length
393393
) {
394-
// If there is only one wallet available, make it default
395-
preferenceSettings.requestChangePreferredWalletId(wallets[0].getWalletId());
394+
// If there is no default wallet set in preferences or the default wallet is not available anymore:
395+
const myGroupId = osparc.auth.Data.getInstance().getGroupId();
396+
const myWallet = wallets.find(wallet => wallet.getOwner() === myGroupId);
397+
if (myWallet) {
398+
// select the personal wallet if it exists
399+
preferenceSettings.requestChangePreferredWalletId(myWallet.getWalletId());
400+
} else {
401+
// otherwise select the first wallet available
402+
preferenceSettings.requestChangePreferredWalletId(wallets[0].getWalletId());
403+
}
396404
} else if (preferenceWalletId) {
397405
const walletFound = wallets.find(wallet => wallet.getWalletId() === preferenceWalletId);
398406
if (walletFound) {

0 commit comments

Comments
 (0)