Call connectMember before pairing

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

View File

@ -55,7 +55,15 @@ async function onScanSuccess(decodedText: any, decodedResult: any) {
html5QrcodeScanner.clear();
const service = await Services.getInstance();
// Call the sendPairingTx function with the extracted sp_address
await service.sendPairingTx(spAddress);
try {
const member = {
sp_addresses: [spAddress],
}
await service.connectMember([member]);
// await service.sendPairingTx(spAddress);
} catch (e) {
console.error('Failed to pair:', e);
}
} else {
console.error('The scanned URL does not contain the sp_address parameter.');
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 pairingAddress = urlParams.get('sp_address');
if (pairingAddress) {
setTimeout(async () => await services.sendPairingTx(pairingAddress), 2000);
setTimeout(async () => {
// await services.sendPairingTx(pairingAddress)
try {
await services.connectMember([{sp_addresses: [pairingAddress]}]);
} catch (e) {
console.error('Failed to pair:', e);
}
}, 2000);
}
await navigate('home');
}

View File

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