diff --git a/src/models/backup.model.ts b/src/models/backup.model.ts
index 0b660f3..bb36699 100644
--- a/src/models/backup.model.ts
+++ b/src/models/backup.model.ts
@@ -1,4 +1,4 @@
-import { Device, Process, SecretsStore } from ".././pkg/sdk_client.js";
+import { Device, Process, SecretsStore } from "../../pkg/sdk_client.js";
export interface BackUp {
device: Device,
diff --git a/src/pages/account/account.ts b/src/pages/account/account.ts
index 3e05daa..a3b567b 100755
--- a/src/pages/account/account.ts
+++ b/src/pages/account/account.ts
@@ -188,16 +188,16 @@ class AccountElement extends HTMLElement {
('.banner-image');
-
+
if (!bannerImg) {
bannerImg = document.createElement('img');
bannerImg.className = 'banner-image';
navbarSection.insertBefore(bannerImg, navbarSection.firstChild);
}
-
+
bannerImg.src = imageUrl;
}
@@ -368,7 +368,7 @@ private markAsRead(processName: string, messageId: number, element: HTMLElement)
element.classList.remove('unread');
element.classList.add('read');
-
+
const statusIcon = element.querySelector('.notification-status');
if (statusIcon) {
statusIcon.innerHTML = `
@@ -381,7 +381,7 @@ private markAsRead(processName: string, messageId: number, element: HTMLElement)
const countElement = this.shadowRoot?.querySelector(`.notification-count[data-process="${processName}"]`);
if (countElement) {
countElement.textContent = `${notifCount.unread}/${notifCount.total}`;
-
+
const bellContainer = countElement.closest('.notification-container');
const bell = bellContainer?.querySelector('svg'); // Changé de .fa-bell à svg
if (bell && bellContainer && notifCount.unread === 0) {
@@ -418,7 +418,7 @@ private exportRecovery(): void {
if (result.isConfirmed) {
const recoveryWords = this.generateRecoveryWords();
localStorage.setItem('recoveryWords', JSON.stringify(recoveryWords));
-
+
Swal.fire({
title: 'Your Recovery Words',
html: `
@@ -447,7 +447,7 @@ private exportRecovery(): void {
if (result.isConfirmed) {
// Stocker l'état du bouton dans le localStorage
localStorage.setItem('recoveryExported', 'true');
-
+
const exportRecoveryBtn = this.shadowRoot?.querySelector('.recovery-btn') as HTMLButtonElement;
if (exportRecoveryBtn) {
exportRecoveryBtn.disabled = true;
@@ -627,8 +627,8 @@ private updateTableContent(rows: Row[]): void {
${row.column2} |
${row.column3} |
-
@@ -677,18 +677,18 @@ private confirmRowPairing(): void {
isAddingRow = false;
currentRow = null;
-
+
this.resetButtonContainer();
this.updateTableContent(rows);
}
private cancelRowPairing(): void {
if (!currentRow) return;
-
+
currentRow.remove();
isAddingRow = false;
currentRow = null;
-
+
this.resetButtonContainer();
}
@@ -739,7 +739,7 @@ private deleteRowPairing(button: HTMLButtonElement): void {
const index = Array.from(table.children).indexOf(row);
const storageKey = STORAGE_KEYS[currentMode];
const rows = JSON.parse(localStorage.getItem(storageKey) || '[]');
-
+
// Supprimer du localStorage
if (index > -1) {
rows.splice(index, 1);
@@ -771,7 +771,7 @@ private editDeviceName(cell: HTMLTableCellElement): void {
input.type = 'text';
input.value = currentValue;
input.className = 'edit-input';
-
+
input.addEventListener('blur', () => this.finishEditing(cell, input));
input.addEventListener('keypress', (e: KeyboardEvent) => {
if (e.key === 'Enter') {
@@ -797,7 +797,7 @@ private async finishEditing(cell: HTMLTableCellElement, input: HTMLInputElement)
const service = await Services.getInstance();
const pairingProcessId = service.getPairingProcessId();
const process = await service.getProcess(pairingProcessId);
-
+ if (!process) throw new Error('Pairing process not found');
// Mettre à jour le nom via le service
await service.updateMemberPublicName(process, newValue);
@@ -816,17 +816,17 @@ private async finishEditing(cell: HTMLTableCellElement, input: HTMLInputElement)
private handleAvatarUpload(event: Event): void {
const input = event.target as HTMLInputElement;
const file = input.files?.[0];
-
+
if (file) {
const reader = new FileReader();
reader.onload = (e: ProgressEvent) => {
const result = e.target?.result as string;
const popupAvatar = this.shadowRoot?.getElementById('popup-avatar-img') as HTMLImageElement;
const navAvatar = this.shadowRoot?.querySelector('.nav-wrapper .avatar') as HTMLImageElement;
-
+
if (popupAvatar) popupAvatar.src = result;
if (navAvatar) navAvatar.src = result;
-
+
localStorage.setItem('userAvatar', result);
};
reader.readAsDataURL(file);
@@ -856,8 +856,9 @@ private async showProcess(): Promise {
const service = await Services.getInstance();
const myProcesses = await service.getMyProcesses();
if (myProcesses && myProcesses.length != 0) {
- const myProcessesDataUnfiltered: { name: string, publicData: Record }[] = await Promise.all(myProcesses.map(async processId => {
+ const myProcessesDataUnfiltered = await Promise.all(myProcesses.map(async processId => {
const process = await service.getProcess(processId);
+ if (!process) return undefined;
const lastState = service.getLastCommitedState(process);
if (!lastState) {
return {
@@ -879,9 +880,9 @@ private async showProcess(): Promise {
publicData: publicData
};
}));
- const myProcessesData = myProcessesDataUnfiltered.filter(
- (p) => p.name !== '' && Object.keys(p.publicData).length != 0
- );
+ const myProcessesData = (myProcessesDataUnfiltered.filter(
+ (p) => p && p.name !== '' && Object.keys(p.publicData).length != 0
+ )) as { name: string, publicData: Record }[];
createProcessTab(container, myProcessesData);
} else {
@@ -896,15 +897,15 @@ private showProcessNotifications(processName: string): void {
const modal = document.createElement('div');
modal.className = 'notifications-modal';
-
+
let notificationsList = process.notification.messages.map(msg => `
-
- ${msg.read ?
+ ${msg.read ?
` ` :
+ ` :
` `
@@ -959,7 +960,7 @@ private showContractPopup(contractId: string, event?: Event) {
if (event) {
event.preventDefault();
}
-
+
// Check if the contract exists in mockContracts
const contract = mockContracts[contractId as keyof typeof mockContracts];
if (!contract) {
@@ -989,7 +990,7 @@ private showContractPopup(contractId: string, event?: Event) {
const closeBtn = popup.querySelector('.close-contract-popup');
const closePopup = () => popup.remove();
-
+
closeBtn?.addEventListener('click', closePopup);
popup.addEventListener('click', (e) => {
if (e.target === popup) closePopup();
@@ -1011,13 +1012,13 @@ private hideAllContent(): void {
private async showPairing(): Promise {
const service = await Services.getInstance();
const spAddress = await service.getDeviceAddress();
-
+
isAddingRow = false;
currentRow = null;
currentMode = 'pairing';
-
+
this.hideAllContent();
-
+
const headerElement = this.shadowRoot?.getElementById('parameter-header');
if (headerElement) {
headerElement.textContent = 'Pairing';
@@ -1047,23 +1048,23 @@ private async showPairing(): Promise {
`;
let rows = JSON.parse(localStorage.getItem(STORAGE_KEYS.pairing) || '[]');
-
+
const deviceExists = rows.some((row: Row) => row.column1 === spAddress);
-
+
if (!deviceExists && spAddress) {
const emojis = await addressToEmoji(spAddress);
-
+
try {
// Déboguer le processus de pairing
const pairingProcessId = await service.getPairingProcessId();
console.log('Pairing Process ID:', pairingProcessId);
-
+
const pairingProcess = await service.getProcess(pairingProcessId);
console.log('Pairing Process:', pairingProcess);
-
- const userName = pairingProcess?.states?.[0]?.public_data?.memberPublicName
+
+ const userName = pairingProcess?.states?.[0]?.public_data?.memberPublicName
|| localStorage.getItem('userName')
-
+
console.log('Username found:', userName);
const newRow = {
@@ -1084,7 +1085,7 @@ private async showPairing(): Promise {
localStorage.setItem(STORAGE_KEYS.pairing, JSON.stringify(rows));
}
}
-
+
this.updateTableContent(rows);
}
}
@@ -1095,11 +1096,11 @@ private showWallet(): void {
currentMode = 'wallet';
this.hideAllContent();
-
+
// Mettre à jour le titre
const headerTitle = this.shadowRoot?.getElementById('header-title');
if (headerTitle) headerTitle.textContent = 'Wallet';
-
+
const walletContent = this.shadowRoot?.getElementById('wallet-content');
if (!walletContent) return;
walletContent.style.display = 'block';
@@ -1121,7 +1122,7 @@ private showWallet(): void {
`;
-
+
const rows = JSON.parse(localStorage.getItem(STORAGE_KEYS.wallet) || '[]');
this.updateWalletTableContent(rows);
}
@@ -1144,10 +1145,10 @@ private showData(): void {
//console.log("showData called");
currentMode = 'data';
this.hideAllContent();
-
+
const headerTitle = this.shadowRoot?.getElementById('header-title');
if (headerTitle) headerTitle.textContent = 'Data';
-
+
const dataContent = this.shadowRoot?.getElementById('data-content');
if (dataContent) {
dataContent.style.display = 'block';
@@ -1169,7 +1170,7 @@ private showData(): void {
`;
-
+
const rows = mockDataRows || JSON.parse(localStorage.getItem(STORAGE_KEYS.data) || '[]');
this.updateDataTableContent(rows);
}
@@ -1198,7 +1199,7 @@ private addWalletRow(): void {
// Remplacer le bouton "Add a line" par les boutons de confirmation/annulation
const buttonContainer = this.shadowRoot?.querySelector('#wallet-content .button-container');
if (!buttonContainer) return;
-
+
buttonContainer.innerHTML = `
@@ -1236,20 +1237,20 @@ private confirmWalletRow(): void {
private cancelWalletRow(): void {
if (!currentRow) return;
-
+
currentRow.remove();
isAddingRow = false;
currentRow = null;
-
+
// Réinitialiser le conteneur de boutons avec le bouton "Add a line"
const buttonContainer = this.shadowRoot?.querySelector('#wallet-content .button-container');
if (!buttonContainer) return;
-
+
buttonContainer.innerHTML = `
`;
-
+
}
private updateDataTableContent(rows: DataRow[]): void {
@@ -1318,7 +1319,7 @@ private openAvatarPopup(): void {
${savedAddress}
-
+
|