From da882706c0cefb8f1ae6e604a04ffd3f00cc68ce Mon Sep 17 00:00:00 2001 From: Clockwork Date: Wed, 20 Mar 2024 10:14:52 +0200 Subject: [PATCH 1/3] feat: Add event bus to trigger wallet --- package.json | 1 + pnpm-lock.yaml | 9 ++++++-- src/bus/index.ts | 5 +++++ src/components/popups/WalletConnect.vue | 4 ++++ src/views/ProposalView.vue | 30 +++++++++++++++++++++++-- 5 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 src/bus/index.ts diff --git a/package.json b/package.json index 24813a3..884f35b 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "dompurify": "^3.0.9", "graphql": "^16.8.1", "graphql-tag": "^2.12.6", + "mitt": "^3.0.1", "vite-plugin-node-polyfills": "^0.21.0", "vue": "^3.4.15", "vue-i18n": "9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a88b153..db765ae 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -50,6 +50,9 @@ dependencies: graphql-tag: specifier: ^2.12.6 version: 2.12.6(graphql@16.8.1) + mitt: + specifier: ^3.0.1 + version: 3.0.1 vite-plugin-node-polyfills: specifier: ^0.21.0 version: 0.21.0(vite@5.0.12) @@ -5561,6 +5564,10 @@ packages: engines: {node: '>=16 || 14 >=14.17'} dev: true + /mitt@3.0.1: + resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==} + dev: false + /mlly@1.5.0: resolution: {integrity: sha512-NPVQvAY1xr1QoVeG0cy8yUYC7FQcOx6evl/RjT1wL5FvzPnzOysoqB/jmx/DhssT2dYa8nxECLAaFI/+gVLhDQ==} dependencies: @@ -6315,7 +6322,6 @@ packages: react: 16.14.0 scheduler: 0.19.1 dev: false - bundledDependencies: false /react-is@16.13.1: resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} @@ -6332,7 +6338,6 @@ packages: object-assign: 4.1.1 prop-types: 15.8.1 dev: false - bundledDependencies: false /read-cache@1.0.0: resolution: {integrity: sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==} diff --git a/src/bus/index.ts b/src/bus/index.ts new file mode 100644 index 0000000..8f33b8d --- /dev/null +++ b/src/bus/index.ts @@ -0,0 +1,5 @@ +import mitt from "mitt"; + +const bus = mitt(); + +export { bus }; diff --git a/src/components/popups/WalletConnect.vue b/src/components/popups/WalletConnect.vue index 25fb6c0..38e684d 100644 --- a/src/components/popups/WalletConnect.vue +++ b/src/components/popups/WalletConnect.vue @@ -4,6 +4,7 @@ import ConnectButton from "../ui/ConnectButton.vue"; import { Ref, computed, ref } from "vue"; import { shorten } from "../../utility"; import UserBalance from "../helper/UserBalance.vue"; +import { bus } from "@/bus"; const isOpen = ref(false); const isConnecting = ref(false); @@ -56,6 +57,9 @@ const cancelConnect = () => { isOpen.value = false; isError.value = false; }; +bus.on("open", () => { + isOpen.value = true; +});