From 47501ae91748ff6a11bf80ae89e3834bcb517a8c Mon Sep 17 00:00:00 2001 From: Jose Olarte III Date: Mon, 26 May 2025 19:23:41 +0800 Subject: [PATCH] Linting --- src/components/DataExportSection.vue | 2 +- src/db/index.ts | 21 +++++++++++++++------ src/libs/util.ts | 6 ++++-- src/views/ContactQRScanShowView.vue | 10 +++++++--- src/views/NewIdentifierView.vue | 10 +++++++--- 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/components/DataExportSection.vue b/src/components/DataExportSection.vue index be565536..a0d3eaca 100644 --- a/src/components/DataExportSection.vue +++ b/src/components/DataExportSection.vue @@ -136,7 +136,7 @@ export default class DataExportSection extends Vue { transform: (table, value, key) => { if (table === "contacts") { // Dexie inserts a number 0 when some are undefined, so we need to totally remove them. - Object.keys(value).forEach(prop => { + Object.keys(value).forEach((prop) => { if (value[prop] === undefined) { delete value[prop]; } diff --git a/src/db/index.ts b/src/db/index.ts index 444a98db..82a7958d 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -90,7 +90,10 @@ db.on("populate", async () => { try { await db.settings.add(DEFAULT_SETTINGS); } catch (error) { - console.error("Error populating the database with default settings:", error); + console.error( + "Error populating the database with default settings:", + error, + ); } }); @@ -105,7 +108,7 @@ async function safeOpenDatabase(retries = 1, delay = 500): Promise { // Create a promise that rejects after 5 seconds const timeoutPromise = new Promise((_, reject) => { - setTimeout(() => reject(new Error('Database open timed out')), 500); + setTimeout(() => reject(new Error("Database open timed out")), 500); }); // Race between the open operation and the timeout @@ -123,7 +126,7 @@ async function safeOpenDatabase(retries = 1, delay = 500): Promise { console.error(`Attempt ${i + 1}: Database open failed:`, error); if (i < retries - 1) { console.log(`Attempt ${i + 1}: Waiting ${delay}ms before retry...`); - await new Promise(resolve => setTimeout(resolve, delay)); + await new Promise((resolve) => setTimeout(resolve, delay)); } else { throw error; } @@ -145,10 +148,16 @@ export async function updateDefaultSettings( await safeOpenDatabase(); } catch (openError: unknown) { console.error("Failed to open database:", openError); - const errorMessage = openError instanceof Error ? openError.message : String(openError); - throw new Error(`Database connection failed: ${errorMessage}. Please try again or restart the app.`); + const errorMessage = + openError instanceof Error ? openError.message : String(openError); + throw new Error( + `Database connection failed: ${errorMessage}. Please try again or restart the app.`, + ); } - const result = await db.settings.update(MASTER_SETTINGS_KEY, settingsChanges); + const result = await db.settings.update( + MASTER_SETTINGS_KEY, + settingsChanges, + ); return result; } catch (error) { console.error("Error updating default settings:", error); diff --git a/src/libs/util.ts b/src/libs/util.ts index b98f747c..3ee008b0 100644 --- a/src/libs/util.ts +++ b/src/libs/util.ts @@ -549,11 +549,13 @@ export const generateSaveAndActivateIdentity = async (): Promise => { mnemonic: mnemonic, publicKeyHex: newId.keys[0].publicKeyHex, }); - + await updateDefaultSettings({ activeDid: newId.did }); } catch (error) { console.error("Failed to update default settings:", error); - throw new Error("Failed to set default settings. Please try again or restart the app."); + throw new Error( + "Failed to set default settings. Please try again or restart the app.", + ); } await updateAccountSettings(newId.did, { isRegistered: false }); return newId.did; diff --git a/src/views/ContactQRScanShowView.vue b/src/views/ContactQRScanShowView.vue index 65257a15..f9351cf5 100644 --- a/src/views/ContactQRScanShowView.vue +++ b/src/views/ContactQRScanShowView.vue @@ -726,9 +726,11 @@ export default class ContactQRScanShow extends Vue { // Apply mirroring after a short delay to ensure video element is ready setTimeout(() => { - const videoElement = document.querySelector('.qr-scanner video') as HTMLVideoElement; + const videoElement = document.querySelector( + ".qr-scanner video", + ) as HTMLVideoElement; if (videoElement) { - videoElement.style.transform = 'scaleX(-1)'; + videoElement.style.transform = "scaleX(-1)"; } }, 1000); } @@ -943,7 +945,9 @@ export default class ContactQRScanShow extends Vue { // Add method to detect desktop browser private detectDesktopBrowser(): boolean { const userAgent = navigator.userAgent.toLowerCase(); - return !/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent); + return !/android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test( + userAgent, + ); } // Update the computed property for camera mirroring diff --git a/src/views/NewIdentifierView.vue b/src/views/NewIdentifierView.vue index 547c43ca..7613b6ff 100644 --- a/src/views/NewIdentifierView.vue +++ b/src/views/NewIdentifierView.vue @@ -34,9 +34,13 @@
Error Creating Identity - +

- Try fully restarting the app. If that doesn't work, back up all data (identities and other data) and reinstall the app. + Try fully restarting the app. If that doesn't work, back up all data + (identities and other data) and reinstall the app.

@@ -85,7 +89,7 @@ export default class NewIdentifierView extends Vue { .catch((error) => { this.loading = false; this.hitError = true; - console.error('Failed to generate identity:', error); + console.error("Failed to generate identity:", error); }); } }