Address paste fix + closeConfirmationModal fix
This commit is contained in:
parent
126f850f9f
commit
a620272dd9
@ -76,7 +76,7 @@ export default class Routing {
|
||||
window.onclick = (event) => {
|
||||
const modal = document.getElementById('modal');
|
||||
if (event.target === modal) {
|
||||
this.confirmPairing();
|
||||
this.closeConfirmationModal();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -109,6 +109,8 @@ export default class Routing {
|
||||
}
|
||||
|
||||
async closeConfirmationModal() {
|
||||
const service = await Services.getInstance()
|
||||
await service.unpairDevice()
|
||||
const modal = document.getElementById('modal')
|
||||
if (modal) modal.style.display = 'none';
|
||||
}
|
||||
|
@ -27,10 +27,10 @@ export default class Services {
|
||||
private websocketConnection: WebSocketClient | null = null;
|
||||
private processes: IProcess[] | null = null;
|
||||
private notifications: INotification[] | null = null;
|
||||
private subscriptions: {element: Element; event: string; eventHandler: string;}[] = [] ;
|
||||
private subscriptions: { element: Element; event: string; eventHandler: string; }[] = [];
|
||||
private database: any
|
||||
// Private constructor to prevent direct instantiation from outside
|
||||
private constructor() {}
|
||||
private constructor() { }
|
||||
|
||||
// Method to access the singleton instance of Services
|
||||
public static async getInstance(): Promise<Services> {
|
||||
@ -101,7 +101,7 @@ export default class Services {
|
||||
}
|
||||
const copyBtn = document.getElementById('copyBtn');
|
||||
if (copyBtn) {
|
||||
copyBtn.addEventListener('click', () => this.copyToClipboard(text));
|
||||
copyBtn.addEventListener('click', () => this.copyToClipboard(currentUrl + "?sp_address=" + text));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
@ -158,7 +158,7 @@ export default class Services {
|
||||
}
|
||||
|
||||
//Get emojis from other device
|
||||
public async emojisPairingRequest () {
|
||||
public async emojisPairingRequest() {
|
||||
try {
|
||||
const container = document.getElementById('containerId');
|
||||
|
||||
@ -174,7 +174,7 @@ export default class Services {
|
||||
const emojiDisplay = container?.querySelector('.pairing-request');
|
||||
|
||||
if (emojiDisplay) {
|
||||
emojiDisplay.textContent = "(Request from: " +emojis+")";
|
||||
emojiDisplay.textContent = "(Request from: " + emojis + ")";
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
@ -209,8 +209,23 @@ export default class Services {
|
||||
const okButton = document.getElementById('okButton');
|
||||
|
||||
addressInput.addEventListener('input', async () => {
|
||||
const address = addressInput.value;
|
||||
let address = addressInput.value;
|
||||
|
||||
// Vérifie si l'adresse est une URL
|
||||
try {
|
||||
const url = new URL(address);
|
||||
// Si c'est une URL valide, extraire le paramètre sp_address
|
||||
const urlParams = new URLSearchParams(url.search);
|
||||
const extractedAddress = urlParams.get('sp_address') || ''; // Prend sp_address ou une chaîne vide
|
||||
|
||||
if (extractedAddress) {
|
||||
address = extractedAddress;
|
||||
addressInput.value = address; // Met à jour l'input pour afficher uniquement l'adresse extraite
|
||||
}
|
||||
} catch (e) {
|
||||
// Si ce n'est pas une URL valide, on garde l'adresse originale
|
||||
console.log("Ce n'est pas une URL valide, on garde l'adresse originale.");
|
||||
}
|
||||
|
||||
if (address) {
|
||||
const emojis = await this.addressToEmoji(address);
|
||||
@ -235,7 +250,7 @@ export default class Services {
|
||||
this.onOkButtonClick();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async onOkButtonClick() {
|
||||
const addressInput = (document.getElementById('addressInput') as HTMLInputElement).value;
|
||||
@ -266,7 +281,7 @@ export default class Services {
|
||||
"roles": {
|
||||
"owner": {
|
||||
"members":
|
||||
[{sp_addresses: [myAddress, recipientAddress]}],
|
||||
[{ sp_addresses: [myAddress, recipientAddress] }],
|
||||
"validation_rules":
|
||||
[
|
||||
{
|
||||
@ -312,7 +327,7 @@ export default class Services {
|
||||
return
|
||||
}
|
||||
|
||||
setTimeout( async () => {
|
||||
setTimeout(async () => {
|
||||
const apiReturn = this.prepareProcessTx(localAddress, spAddress)
|
||||
await this.handleApiReturn(apiReturn);
|
||||
}, 100)
|
||||
@ -373,7 +388,7 @@ export default class Services {
|
||||
try {
|
||||
// console.log('==============> sending txxxxxxx parser', tx)
|
||||
const parsedTx = await this.sdkClient.parse_new_tx(tx, 0, 0.0001)
|
||||
if(parsedTx) {
|
||||
if (parsedTx) {
|
||||
console.log("🚀 ~ Services ~ parseNewTx ~ parsedTx:", parsedTx)
|
||||
try {
|
||||
await this.handleApiReturn(parsedTx);
|
||||
@ -383,7 +398,7 @@ export default class Services {
|
||||
console.error("Failed to update device with new tx");
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
} catch (e) {
|
||||
console.trace(e);
|
||||
}
|
||||
}
|
||||
@ -415,7 +430,7 @@ export default class Services {
|
||||
}
|
||||
}
|
||||
|
||||
if(apiReturn.updated_cached_msg && apiReturn.updated_cached_msg.length) {
|
||||
if (apiReturn.updated_cached_msg && apiReturn.updated_cached_msg.length) {
|
||||
apiReturn.updated_cached_msg.forEach((msg, index) => {
|
||||
// console.debug(`CachedMessage ${index}:`, msg);
|
||||
// Save the message to local storage
|
||||
@ -691,14 +706,14 @@ export default class Services {
|
||||
document.head.appendChild(newScript).parentNode?.removeChild(newScript);
|
||||
|
||||
this.processes = await this.getProcesses();
|
||||
if(this.processes) {
|
||||
if (this.processes) {
|
||||
this.setProcessesInSelectElement(this.processes)
|
||||
}
|
||||
}
|
||||
|
||||
public async setProcessesInSelectElement(processList: any[]) {
|
||||
const select = document.querySelector(".select-field");
|
||||
if(select) {
|
||||
if (select) {
|
||||
for (const process of processList) {
|
||||
const option = document.createElement("option");
|
||||
option.setAttribute("value", process.name);
|
||||
@ -707,11 +722,11 @@ export default class Services {
|
||||
}
|
||||
}
|
||||
const optionList = document.querySelector('.autocomplete-list');
|
||||
if(optionList) {
|
||||
if (optionList) {
|
||||
const observer = new MutationObserver((mutations, observer) => {
|
||||
const options = optionList.querySelectorAll('li')
|
||||
if(options) {
|
||||
for(const option of options) {
|
||||
if (options) {
|
||||
for (const option of options) {
|
||||
this.addSubscription(option, 'click', 'showSelectedProcess')
|
||||
}
|
||||
}
|
||||
@ -730,7 +745,7 @@ export default class Services {
|
||||
|
||||
public async showSelectedProcess(event: MouseEvent) {
|
||||
const elem = event.target;
|
||||
if(elem) {
|
||||
if (elem) {
|
||||
|
||||
const cardContent = document.querySelector(".card-content");
|
||||
|
||||
@ -753,7 +768,7 @@ export default class Services {
|
||||
this.addSubscription(zoneElement, 'click', 'goToProcessPage')
|
||||
processDiv.appendChild(zoneElement);
|
||||
}
|
||||
if(cardContent) cardContent.appendChild(processDiv);
|
||||
if (cardContent) cardContent.appendChild(processDiv);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -762,8 +777,8 @@ export default class Services {
|
||||
const target = event.target as HTMLDivElement;
|
||||
const zoneId = target?.getAttribute('zone-id');
|
||||
const processList = document.querySelectorAll('.process-element');
|
||||
if(processList) {
|
||||
for(const process of processList) {
|
||||
if (processList) {
|
||||
for (const process of processList) {
|
||||
process.classList.remove('selected')
|
||||
}
|
||||
}
|
||||
@ -848,11 +863,11 @@ export default class Services {
|
||||
const badge = document.querySelector('.notification-badge') as HTMLDivElement
|
||||
const notifications = this.notifications
|
||||
const noNotifications = document.querySelector('.no-notification') as HTMLDivElement
|
||||
if(notifications?.length) {
|
||||
if (notifications?.length) {
|
||||
badge.innerText = notifications.length.toString()
|
||||
const notificationBoard = document.querySelector('.notification-board') as HTMLDivElement
|
||||
noNotifications.style.display = 'none'
|
||||
for(const notif of notifications) {
|
||||
for (const notif of notifications) {
|
||||
const notifElement = document.createElement("div");
|
||||
notifElement.className = "notification-element";
|
||||
notifElement.setAttribute('notif-id', notif.id.toString())
|
||||
|
Loading…
x
Reference in New Issue
Block a user