From 4b0ed0ba9f4c10a47de7dc2830dbf6953bb32a66 Mon Sep 17 00:00:00 2001 From: Adwait Gharpure <69599306+Adw8@users.noreply.github.com> Date: Thu, 7 Mar 2024 19:28:30 +0530 Subject: [PATCH] Add toast on session approval (#46) * Add toast on session_approval * Handle case where request icon is null * Change camera permission message * Fix comments * Fix import order --------- Co-authored-by: Adw8 --- App.tsx | 17 +++++++++++++++-- components/PairingModal.tsx | 2 ++ components/SignRequest.tsx | 12 ++++++------ components/WalletConnect.tsx | 4 +++- types.ts | 1 + 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/App.tsx b/App.tsx index 716d145..118e126 100644 --- a/App.tsx +++ b/App.tsx @@ -1,4 +1,5 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'; +import { Snackbar } from 'react-native-paper'; import { SignClientTypes } from '@walletconnect/types'; import { NavigationContainer } from '@react-navigation/native'; @@ -30,7 +31,7 @@ const App = (): React.JSX.Element => { const { requestSession, setRequestSession } = useRequests(); const [modalVisible, setModalVisible] = useState(false); - //TODO: Remove any + const [toastVisible, setToastVisible] = useState(false); const [currentProposal, setCurrentProposal] = useState< SignClientTypes.EventArguments['session_proposal'] | undefined >(); @@ -85,7 +86,7 @@ const App = (): React.JSX.Element => { web3wallet?.off('session_proposal', onSessionProposal); web3wallet?.off('session_request', onSessionRequest); }; - //TODO: Investigate dependancies + //TODO: Investigate dependencies }); const linking = { @@ -147,7 +148,19 @@ const App = (): React.JSX.Element => { currentProposal={currentProposal} setCurrentProposal={setCurrentProposal} currentEthAddresses={currentEthAddresses} + setToastVisible={setToastVisible} /> + setToastVisible(false)} + action={{ + label: 'Ok', + onPress: () => { + setToastVisible(false); + }, + }}> + Session approved + ); }; diff --git a/components/PairingModal.tsx b/components/PairingModal.tsx index d29466c..6f2c9cc 100644 --- a/components/PairingModal.tsx +++ b/components/PairingModal.tsx @@ -15,6 +15,7 @@ const PairingModal = ({ currentEthAddresses, setCurrentProposal, setModalVisible, + setToastVisible, }: PairingModalProps) => { const url = currentProposal?.params?.proposer?.metadata.url; const methods = currentProposal?.params?.requiredNamespaces.eip155.methods; @@ -47,6 +48,7 @@ const PairingModal = ({ }); setModalVisible(false); + setToastVisible(true); setCurrentProposal(undefined); } }; diff --git a/components/SignRequest.tsx b/components/SignRequest.tsx index 9280cd8..92f088a 100644 --- a/components/SignRequest.tsx +++ b/components/SignRequest.tsx @@ -160,12 +160,12 @@ const SignRequest = ({ route }: SignRequestProps) => { ) : ( - + {requestIcon && ( + + )} {requestName} {requestURL} diff --git a/components/WalletConnect.tsx b/components/WalletConnect.tsx index eeac98d..64a489c 100644 --- a/components/WalletConnect.tsx +++ b/components/WalletConnect.tsx @@ -62,7 +62,9 @@ const WalletConnect = () => { {!hasPermission || !device ? ( - {!hasPermission ? 'No Camera Permission!' : 'No Camera Selected!'} + {!hasPermission + ? 'No Camera Permission granted' + : 'No Camera Selected'} ) : ( <> diff --git a/types.ts b/types.ts index 98e76da..8aac72b 100644 --- a/types.ts +++ b/types.ts @@ -98,6 +98,7 @@ export interface PairingModalProps { setCurrentProposal: ( arg1: SignClientTypes.EventArguments['session_proposal'] | undefined, ) => void; + setToastVisible: (arg1: boolean) => void; } export interface SignModalProps {