Skip to content

Commit

Permalink
show approve modal inside useEffect to wait for setConnectURI to finish
Browse files Browse the repository at this point in the history
  • Loading branch information
tiero committed Dec 6, 2023
1 parent 6cbc5df commit 08b63f4
Show file tree
Hide file tree
Showing 3 changed files with 734 additions and 5,135 deletions.
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"version": "0.0.1",
"main": "./src/index.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web",
"start": "npx expo start",
"android": "npx expo start --android",
"ios": "npx expo start --ios",
"web": "npx expo start --web",
"format": "prettier --write ./src/**/*.{ts,tsx}",
"format:check": "prettier --check ./src/**/*.{ts,tsx}",
"lint": "eslint ./src/**/*.{ts,tsx}",
Expand All @@ -32,7 +32,7 @@
"nostr-tools": "^1.1.1",
"react": "18.1.0",
"react-dom": "18.1.0",
"react-native": "0.70.5",
"react-native": "0.70.8",
"react-native-gesture-handler": "^2.8.0",
"react-native-get-random-values": "^1.8.0",
"react-native-reanimated": "~2.12.0",
Expand All @@ -55,7 +55,6 @@
"@typescript-eslint/parser": "^5.48.0",
"eslint": "^8.31.0",
"eslint-config-universe": "^11.1.1",
"expo-cli": "^6.1.0",
"prettier": "^2.8.1",
"typescript": "^4.6.3"
},
Expand Down
12 changes: 7 additions & 5 deletions src/screens/ConnectList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,31 +156,33 @@ export default function ConnectList({ navigation }: { navigation: any }) {
})();
}, [navigation, handler]);

useEffect(() => {
if (!connectURI) return;
approveConnectModalShow();
}, [connectURI]);

const scanQRCode = () => {
inputChoiceModalDismiss();
setScanner(true);
};

const handleBarCodeScanned = ({ data }: { type: string; data: string }) => {
setScanner(false);
try {
const uri = ConnectURI.fromURI(data);
setConnectURI(uri);
setScanner(false);
approveConnectModalShow();
} catch (err: any) {
console.error(err);
alert('Invalid Connect URI');
}
};

const pasteFromClipboard = async () => {
inputChoiceModalDismiss();
try {
const text = await Clipboard.getStringAsync();
if (!text) throw new Error('No text in clipboard');
setConnectURI(ConnectURI.fromURI(text));

inputChoiceModalDismiss();
approveConnectModalShow();
} catch (err: any) {
Alert.alert('Error', err.message);
}
Expand Down
Loading

0 comments on commit 08b63f4

Please sign in to comment.