Skip to content

Commit

Permalink
Only show total user's credit in the current wallet (#5050)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsaq007 authored Nov 20, 2023
1 parent c12b6c7 commit 3e3a25c
Showing 1 changed file with 0 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ qx.Class.define("osparc.navigation.CreditsMenuButton", {
if (currentUsage) {
currentUsage.addListener("changeUsedCredits", () => {
this.__updateCredits();
// this.__animate();
});
}
},
Expand All @@ -97,35 +96,18 @@ qx.Class.define("osparc.navigation.CreditsMenuButton", {
wallet.addListener("changeCreditsAvailable", () => this.__updateCredits());
}
},
// Note - Sometimes it doesn't work and it bring the credits indicator into a failed state
// __animate: function() {
// const label = this.getChildControl("label");
// osparc.utils.Utils.animateUsage(label.getContentElement().getDomElement());
// },

__updateCredits: function() {
const store = osparc.store.Store.getInstance();
const wallet = store.getContextWallet();
if (wallet) {
let text = "-";
const currentUsage = this.getCurrentUsage();
let used = null;
if (currentUsage) {
used = currentUsage.getUsedCredits();
}
const creditsLeft = wallet.getCreditsAvailable();
if (creditsLeft !== null) {
text = "<span style='font-size:12px;display:inline-block'>CREDITS</span><br>";
let nCreditsText = "";
if (used !== null) {
nCreditsText += osparc.desktop.credits.Utils.creditsToFixed(used) + " / ";
}
nCreditsText += osparc.desktop.credits.Utils.creditsToFixed(creditsLeft);
text += `<span>${nCreditsText}</span>`;
this.set({
minWidth: used ? 90 : null,
width: used ? 90 : null
});
}
this.set({
label: text,
Expand Down

0 comments on commit 3e3a25c

Please sign in to comment.