Skip to content

Commit

Permalink
applied a default timer value
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Taras authored and Nick Taras committed Oct 6, 2023
1 parent 737debf commit 1ba483b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 8 deletions.
8 changes: 7 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,13 @@
});

window.negotiator.on("tokens-selected", (tokens) => {
console.log("tokens-selected", tokens);
console.log("tokens-selected 1", tokens);
});
window.negotiator.on("tokens-selected", (tokens) => {
console.log("tokens-selected 2", tokens);
});
window.negotiator.on("tokens-selected", (tokens) => {
console.log("tokens-selected 3", tokens);
});
window.negotiator.on("connected-wallet", (wallet) => {
console.log("connected wallet", wallet);
Expand Down
24 changes: 18 additions & 6 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,11 @@ export class Client {
}

this.eventSender('tokens-loaded', { loadedCollections: Object.keys(this.tokenStore.getCurrentIssuers()).length })

// use retry logic here too
// document.querySelectorAll('.connect-btn-tn .lds-ellipsis').forEach((el) => {
// el.parentElement.innerHTML = this.config.uiOptions?.loadAction ?? 'Load Collection'
// })
}

public cancelTokenAutoload() {
Expand Down Expand Up @@ -669,6 +674,11 @@ export class Client {
this.eventSender('tokens-selected', { selectedTokens: tokens })
this.eventSender('tokens-loaded', { loadedCollections: Object.keys(tokens).length })

// use retry logic here too
// document.querySelectorAll('.connect-btn-tn .lds-ellipsis').forEach((el) => {
// el.parentElement.innerHTML = this.config.uiOptions?.loadAction ?? 'Load Collection'
// })

// Feature not supported when an end users third party cookies are disabled
// because the use of a tab requires a user gesture.
if (this.messaging.core.iframeStorageSupport === false && Object.keys(this.tokenStore.getCurrentTokens(false)).length === 0)
Expand Down Expand Up @@ -758,18 +768,20 @@ export class Client {
private async loadRemoteOutletTokens(issuer: OffChainTokenConfig): Promise<OutletTokenResult | void> {
const redirectRequired = shouldUseRedirectMode(this.config.offChainRedirectMode)
if (redirectRequired) this.tokenStore.setTokens(issuer.collectionID, [])
this.ui.showLoader(
this.ui?.showLoader(
`<h4>${this.config.uiOptions?.reDirectIssuerEventHeading ?? 'Connecting to Issuers...'}</h4>`,
`<small>${this.config.uiOptions?.reDirectIssuerBodyEvent ?? 'Your browser will re-direct shortly'}</small>`,
`<button class='cancel-autoload-btn btn-tn' aria-label='Cancel page re-direct'>${
this.config.uiOptions?.cancelAction ?? 'Cancel'
}</button>`,
)
this.enableTokenAutoLoadCancel()
if (this.config.uiOptions?.userCancelIssuerAutoRedirectTimer) await sleep(this.config.uiOptions.userCancelIssuerAutoRedirectTimer)
if (this.userCancelTokenAutoload) {
this.userCancelTokenAutoload = false
return {}
if (!issuer.onChain) {
this.enableTokenAutoLoadCancel()
await sleep(this.config.uiOptions.userCancelIssuerAutoRedirectTimer ?? 2500)
if (this.userCancelTokenAutoload) {
this.userCancelTokenAutoload = false
return {}
}
}
const res = await this.messaging.sendMessage(
{
Expand Down
4 changes: 3 additions & 1 deletion src/client/views/select-issuers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ export class SelectIssuers extends AbstractView {

protected afterRender() {
if (this.client.issuersLoaded) {
if (this.client.getTokenStore().hasUnloadedTokens()) this.autoLoadTokens()
if (this.client.getTokenStore().hasUnloadedTokens()) {
this.autoLoadTokens()
}
} else {
this.issuersLoading()
}
Expand Down

0 comments on commit 1ba483b

Please sign in to comment.