Radish alpha
r
Radicle web interface
Radicle
Git (anonymous pull)
Log in to clone via SSH
Fix walletconnect rejection from mobile
Alexis Sellier committed 4 years ago
commit f97bc5b5f2860ae3285b1b6b775c197ecca3c928
parent 2043d405fcbceb986550ff20a00f9ab22c833a65
2 files changed +10 -2
modified src/config.ts
@@ -1,4 +1,4 @@
-
import { writable } from "svelte/store";
+
import { get, writable } from "svelte/store";
import type { Writable } from "svelte/store";
import { ethers } from "ethers";
import type { TypedDataSigner } from '@ethersproject/abstract-signer';
@@ -150,7 +150,7 @@ export class Config {
          state.set({ state: "open", uri, onClose });
        },
        close: () => {
-
          state.set({ state: "close" });
+
          // We handle the "close" event through the "disconnect" handler.
        }
      },
      clientMeta: {
@@ -165,6 +165,12 @@ export class Config {
    walletConnect.on("modal_closed", () => {
      state.set({ state: "close" });
    });
+
    walletConnect.on("disconnect", () => {
+
      const wcs = get(state);
+
      if (wcs.state === "open") {
+
        wcs.onClose();
+
      }
+
    });

    const walletConnectSigner = new WalletConnectSigner(walletConnect, provider);

modified src/session.ts
@@ -87,6 +87,7 @@ export const loadState = (initial: State): Store => {

      try {
        await config.walletConnect.client.connect();
+
        console.log("WalletConnect: connected.");

        const address = await signer.getAddress();
        const tokenBalance: BigNumber = await config.token.balanceOf(address);
@@ -103,6 +104,7 @@ export const loadState = (initial: State): Store => {
        }
        store.set({ connection: Connection.Connected, session });
      } catch (e) {
+
        console.log("WalletConnect: connection failed.");
        store.set({ connection: Connection.Disconnected });

        // There seems to be no way to detect this "error" caused by the user