Fix state reset bug on subscription page

This commit is contained in:
silverpill 2022-07-26 17:55:26 +00:00
parent 31f328b0ce
commit f788be7022
3 changed files with 13 additions and 5 deletions

View file

@ -176,9 +176,11 @@ function canConnectWallet(): boolean {
}
function reset() {
senderEthereumAddress = null
subscriptionsEnabled = null
subscription = null
subscriptionState = null
tokenBalance = null
}
async function connectWallet() {
@ -188,7 +190,11 @@ async function connectWallet() {
}
}
watch($$(walletAddress), reset)
watch($$(walletAddress), (newValue) => {
if (newValue === null) {
reset()
}
})
async function checkSubscription() {
if (

View file

@ -115,6 +115,7 @@ function canConnectWallet(): boolean {
}
function reset() {
subscriptionToken = null
subscriptionsEnabled = null
subscription = null
subscriptionState = null
@ -128,7 +129,11 @@ async function connectWallet() {
}
}
watch($$(walletAddress), reset)
watch($$(walletAddress), (newValue) => {
if (newValue === null) {
reset()
}
})
async function checkSubscription() {
if (

View file

@ -85,9 +85,6 @@ async function connectWallet(): Promise<void> {
walletProvider.on("accountsChanged", () => {
disconnectWallet()
})
walletProvider.on("disconnect", () => {
disconnectWallet()
})
}
// Can't use reactive signer object because it doesn't work with ethers.js