Skip to content

Commit

Permalink
feat: add card button hiding & various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
micwallace committed Oct 26, 2023
1 parent 4bcbea8 commit 11183a3
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion javascript/engine-js/src/TokenScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export class TokenScript {
public getCards(tokenOrigin?: string): Card[] {

if (!tokenOrigin)
tokenOrigin = this.getCurrentTokenContext().originId;
tokenOrigin = this.getCurrentTokenContext()?.originId;

if (!this.cards) {

Expand Down
4 changes: 4 additions & 0 deletions javascript/engine-js/src/tokenScript/Card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ export class Card {
return this.view.getAttribute("urlFragment")
}

get uiButton() {
return this.view.hasAttribute("uiButton") ? (this.view.getAttribute("uiButton") === 'true') : true;
}

/**
* Determines whether the view is to be loaded from a URL or from embedded content in ts:view
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export class CardPopover implements IViewBinding {
sandbox="allow-scripts allow-modals allow-forms allow-popups">
</iframe>
</div>
<div class="action-bar" style={{display: this.currentCard?.type == "action" ? "block" : "none"}}>
<div class="action-bar" style={{display: this.currentCard?.type == "action" && this.currentCard?.uiButton ? "block" : "none"}}>
<button class="action-btn btn btn-primary" onClick={() => this.confirmAction()}>{this.currentCard?.label}</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import {Contract, ethers} from "ethers";

const COLLECTION_CACHE_TTL = 86400;
const TOKEN_CACHE_TTL = 3600;
export const BASE_TOKEN_DISCOVERY_URL = //'https://api.token-discovery.tokenscript.org'
'http://localhost:3000'
export const BASE_TOKEN_DISCOVERY_URL = 'https://api.token-discovery.tokenscript.org';
//'http://localhost:3000';

export class DiscoveryAdapter implements ITokenDiscoveryAdapter {

Expand Down

0 comments on commit 11183a3

Please sign in to comment.