mirror of
https://github.com/balzack/databag.git
synced 2025-02-14 12:39:17 +00:00
fixed accepting connection from unsaved
This commit is contained in:
parent
e67f704d53
commit
0e09d981ca
@ -1,7 +1,7 @@
|
||||
import { useEffect, useState, useRef, useContext } from 'react';
|
||||
import SQLite from "react-native-sqlite-storage";
|
||||
|
||||
const DATABAG_DB = 'databag_v039.db';
|
||||
const DATABAG_DB = 'databag_v040.db';
|
||||
|
||||
export function useStoreContext() {
|
||||
const [state, setState] = useState({});
|
||||
|
@ -66,10 +66,18 @@ export function Contact({ contact, closeContact }) {
|
||||
const saveAndConnect = () => {
|
||||
setContact(actions.saveAndConnect);
|
||||
}
|
||||
|
||||
const confirmAndConnect = () => {
|
||||
setContact(actions.confirmAndConnect);
|
||||
}
|
||||
|
||||
const saveContact = () => {
|
||||
setContact(actions.saveContact);
|
||||
}
|
||||
|
||||
const confirmContact = () => {
|
||||
setContact(actions.confirmContact);
|
||||
}
|
||||
|
||||
const ignoreContact = () => {
|
||||
setContact(actions.ignoreContact);
|
||||
@ -186,10 +194,10 @@ export function Contact({ contact, closeContact }) {
|
||||
)}
|
||||
{ state.status === 'pending' && (
|
||||
<>
|
||||
<TouchableOpacity style={styles.button} onPress={saveAndConnect}>
|
||||
<TouchableOpacity style={styles.button} onPress={confirmAndConnect}>
|
||||
<Text style={styles.buttonText}>Save and Connect</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity style={styles.button} onPress={saveContact}>
|
||||
<TouchableOpacity style={styles.button} onPress={confirmContact}>
|
||||
<Text style={styles.buttonText}>Save Contact</Text>
|
||||
</TouchableOpacity>
|
||||
<TouchableOpacity style={styles.button} onPress={deleteContact}>
|
||||
|
@ -101,6 +101,17 @@ export function useContact(contact, close) {
|
||||
}
|
||||
});
|
||||
},
|
||||
confirmAndConnect: async () => {
|
||||
await applyAction(async () => {
|
||||
await card.actions.setCardConfirmed(state.cardId);
|
||||
await card.actions.setCardConnecting(state.cardId);
|
||||
let open = await card.actions.getCardOpenMessage(state.cardId);
|
||||
let contact = await card.actions.setCardOpenMessage(state.node, open);
|
||||
if (contact.status === 'connected') {
|
||||
await card.actions.setCardConnected(state.cardId, contact.token, contact);
|
||||
}
|
||||
});
|
||||
},
|
||||
saveContact: async () => {
|
||||
await applyAction(async () => {
|
||||
let message = await getListingMessage(state.node, state.guid);
|
||||
@ -119,6 +130,11 @@ export function useContact(contact, close) {
|
||||
}
|
||||
});
|
||||
},
|
||||
confirmContact: async () => {
|
||||
await applyAction(async () => {
|
||||
await card.actions.setCardConfirmed(state.cardId);
|
||||
});
|
||||
},
|
||||
ignoreContact: async () => {
|
||||
await applyAction(async () => {
|
||||
await card.actions.setCardConfirmed(state.cardId);
|
||||
|
Loading…
Reference in New Issue
Block a user