Call connectMember before pairing

This commit is contained in:
Sosthene 2024-11-22 16:12:12 +01:00
parent 9f76885b91
commit bc0b4a86f4
3 changed files with 26 additions and 3 deletions

View File

@ -55,7 +55,15 @@ async function onScanSuccess(decodedText: any, decodedResult: any) {
html5QrcodeScanner.clear(); html5QrcodeScanner.clear();
const service = await Services.getInstance(); const service = await Services.getInstance();
// Call the sendPairingTx function with the extracted sp_address // Call the sendPairingTx function with the extracted sp_address
await service.sendPairingTx(spAddress); try {
const member = {
sp_addresses: [spAddress],
}
service.connectMember([member]);
// await service.sendPairingTx(spAddress);
} catch (e) {
console.error('Failed to pair:', e);
}
} else { } else {
console.error('The scanned URL does not contain the sp_address parameter.'); console.error('The scanned URL does not contain the sp_address parameter.');
alert('Invalid QR code: sp_address parameter missing.'); alert('Invalid QR code: sp_address parameter missing.');

View File

@ -112,7 +112,14 @@ async function init(): Promise<void> {
const urlParams = new URLSearchParams(queryString); const urlParams = new URLSearchParams(queryString);
const pairingAddress = urlParams.get('sp_address'); const pairingAddress = urlParams.get('sp_address');
if (pairingAddress) { if (pairingAddress) {
setTimeout(async () => await services.sendPairingTx(pairingAddress), 2000); setTimeout(async () => {
// await services.sendPairingTx(pairingAddress)
try {
services.connectMember([{sp_addresses: [pairingAddress]}]);
} catch (e) {
console.error('Failed to pair:', e);
}
}, 2000);
} }
await navigate('home'); await navigate('home');
} }

View File

@ -148,7 +148,15 @@ export function initAddressInput() {
async function onOkButtonClick() { async function onOkButtonClick() {
const service = await Services.getInstance(); const service = await Services.getInstance();
const addressInput = (document.getElementById('addressInput') as HTMLInputElement).value; const addressInput = (document.getElementById('addressInput') as HTMLInputElement).value;
await service.sendPairingTx(addressInput); const member = {
sp_addresses: [addressInput],
}
try {
service.connectMember([member]);
// await service.sendPairingTx(addressInput);
} catch (e) {
console.error('onOkButtonClick error:', e);
}
} }
export async function generateQRCode(spAddress: string) { export async function generateQRCode(spAddress: string) {