mirror of
https://github.com/balzack/databag.git
synced 2025-02-19 06:29:23 +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 { useEffect, useState, useRef, useContext } from 'react';
|
||||||
import SQLite from "react-native-sqlite-storage";
|
import SQLite from "react-native-sqlite-storage";
|
||||||
|
|
||||||
const DATABAG_DB = 'databag_v039.db';
|
const DATABAG_DB = 'databag_v040.db';
|
||||||
|
|
||||||
export function useStoreContext() {
|
export function useStoreContext() {
|
||||||
const [state, setState] = useState({});
|
const [state, setState] = useState({});
|
||||||
|
@ -67,10 +67,18 @@ export function Contact({ contact, closeContact }) {
|
|||||||
setContact(actions.saveAndConnect);
|
setContact(actions.saveAndConnect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const confirmAndConnect = () => {
|
||||||
|
setContact(actions.confirmAndConnect);
|
||||||
|
}
|
||||||
|
|
||||||
const saveContact = () => {
|
const saveContact = () => {
|
||||||
setContact(actions.saveContact);
|
setContact(actions.saveContact);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const confirmContact = () => {
|
||||||
|
setContact(actions.confirmContact);
|
||||||
|
}
|
||||||
|
|
||||||
const ignoreContact = () => {
|
const ignoreContact = () => {
|
||||||
setContact(actions.ignoreContact);
|
setContact(actions.ignoreContact);
|
||||||
}
|
}
|
||||||
@ -186,10 +194,10 @@ export function Contact({ contact, closeContact }) {
|
|||||||
)}
|
)}
|
||||||
{ state.status === 'pending' && (
|
{ state.status === 'pending' && (
|
||||||
<>
|
<>
|
||||||
<TouchableOpacity style={styles.button} onPress={saveAndConnect}>
|
<TouchableOpacity style={styles.button} onPress={confirmAndConnect}>
|
||||||
<Text style={styles.buttonText}>Save and Connect</Text>
|
<Text style={styles.buttonText}>Save and Connect</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity style={styles.button} onPress={saveContact}>
|
<TouchableOpacity style={styles.button} onPress={confirmContact}>
|
||||||
<Text style={styles.buttonText}>Save Contact</Text>
|
<Text style={styles.buttonText}>Save Contact</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity style={styles.button} onPress={deleteContact}>
|
<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 () => {
|
saveContact: async () => {
|
||||||
await applyAction(async () => {
|
await applyAction(async () => {
|
||||||
let message = await getListingMessage(state.node, state.guid);
|
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 () => {
|
ignoreContact: async () => {
|
||||||
await applyAction(async () => {
|
await applyAction(async () => {
|
||||||
await card.actions.setCardConfirmed(state.cardId);
|
await card.actions.setCardConfirmed(state.cardId);
|
||||||
|
Loading…
Reference in New Issue
Block a user