Skip to content

Commit ffcdd2c

Browse files
committed
fix: Info card reloading after transaction in Mooar and AW views
1 parent 3739ad6 commit ffcdd2c

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

javascript/tokenscript-viewer/src/components/viewers/alphawallet/alphawallet-viewer.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {AppRoot, ShowToastEventArgs} from "../../app/app";
33
import {ITransactionStatus, TokenScript} from "@tokenscript/engine-js/src/TokenScript";
44
import {ITokenCollection} from "@tokenscript/engine-js/src/tokens/ITokenCollection";
55
import {getSingleTokenMetadata} from "../util/getSingleTokenMetadata";
6-
import {Card} from "@tokenscript/engine-js/src/tokenScript/Card";
6+
import {Card, CardType} from "@tokenscript/engine-js/src/tokenScript/Card";
77
import {handleTransactionError, showTransactionNotification} from "../util/showTransactionNotification";
88
import {getCardButtonClass} from "../util/getCardButtonClass";
99
import {ViewBinding} from "../tabbed/viewBinding";
@@ -111,7 +111,6 @@ export class SmartTokenStoreViewer {
111111
this.tokenScript.on("TOKENS_UPDATED", (data) => {
112112
this.cardButtons = null;
113113
this.overflowCardButtons = null;
114-
this.infoCard = null;
115114
this.loadCards();
116115
}, "grid");
117116

@@ -124,15 +123,18 @@ export class SmartTokenStoreViewer {
124123

125124
const cardButtons: JSX.Element[] = [];
126125
const overflowCardButtons: JSX.Element[] = [];
127-
this.infoCard = null;
128126

129127
const cards = this.tokenScript.getCards().filterCards();
130128

131129
for (let [index, card] of cards.entries()){
132130

133131
let label = card.label;
134132

135-
if (card.type === "token" && !this.infoCard){
133+
if (card.type === "token"){
134+
// The card is already loaded, we only need to update other card buttons
135+
if (this.infoCard)
136+
continue;
137+
136138
// Show first info card
137139
this.infoCard = card;
138140
if (!this.infoViewController) {
@@ -145,7 +147,7 @@ export class SmartTokenStoreViewer {
145147
}
146148

147149
if (label === "Unnamed Card")
148-
label = card.type === "token" ? "Token Info" : card.type + " Card";
150+
label = (card.type as CardType) ? "Token Info" : card.type + " Card";
149151

150152
try {
151153
const enabled = await card.isEnabledOrReason();

javascript/tokenscript-viewer/src/components/viewers/mooar/mooar-viewer.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {AppRoot, ShowToastEventArgs} from "../../app/app";
33
import {ITransactionStatus, TokenScript} from "@tokenscript/engine-js/src/TokenScript";
44
import {ITokenCollection} from "@tokenscript/engine-js/src/tokens/ITokenCollection";
55
import {getSingleTokenMetadata} from "../util/getSingleTokenMetadata";
6-
import {Card} from "@tokenscript/engine-js/src/tokenScript/Card";
6+
import {Card, CardType} from "@tokenscript/engine-js/src/tokenScript/Card";
77
import {handleTransactionError, showTransactionNotification} from "../util/showTransactionNotification";
88
import {getCardButtonClass} from "../util/getCardButtonClass";
99
import {ViewBinding} from "../tabbed/viewBinding";
@@ -111,7 +111,6 @@ export class SmartTokenStoreViewer {
111111
this.tokenScript.on("TOKENS_UPDATED", (data) => {
112112
this.cardButtons = null;
113113
this.overflowCardButtons = null;
114-
this.infoCard = null;
115114
this.loadCards();
116115
}, "grid");
117116

@@ -124,15 +123,18 @@ export class SmartTokenStoreViewer {
124123

125124
const cardButtons: JSX.Element[] = [];
126125
const overflowCardButtons: JSX.Element[] = [];
127-
this.infoCard = null;
128126

129127
const cards = this.tokenScript.getCards().filterCards();
130128

131129
for (let [index, card] of cards.entries()){
132130

133131
let label = card.label;
134132

135-
if (card.type === "token" && !this.infoCard){
133+
if (card.type === "token"){
134+
// The card is already loaded, we only need to update other card buttons
135+
if (this.infoCard)
136+
continue;
137+
136138
// Show first info card
137139
this.infoCard = card;
138140
if (!this.infoViewController) {
@@ -145,7 +147,7 @@ export class SmartTokenStoreViewer {
145147
}
146148

147149
if (label === "Unnamed Card")
148-
label = card.type === "token" ? "Token Info" : card.type + " Card";
150+
label = (card.type as CardType) === "token" ? "Token Info" : card.type + " Card";
149151

150152
try {
151153
const enabled = await card.isEnabledOrReason();

0 commit comments

Comments
 (0)