style: fix line length in ContactsView ternary operator
- Break long CSS class strings into multiple concatenated lines - Ensure all lines are under 100 characters for better readability - Maintain same functionality and styling behavior - Improve code maintainability and readability Fixes: Long lines in conditional CSS class assignment
This commit is contained in:
@@ -227,7 +227,7 @@ export default class GivenPrompts extends Vue {
|
|||||||
|
|
||||||
let someContactDbIndex = Math.floor(Math.random() * this.numContacts);
|
let someContactDbIndex = Math.floor(Math.random() * this.numContacts);
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
// as long as the index has an entry, loop
|
// as long as the index has an entry, loop
|
||||||
while (
|
while (
|
||||||
this.shownContactDbIndices[someContactDbIndex] != null &&
|
this.shownContactDbIndices[someContactDbIndex] != null &&
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
|
|||||||
result.columns,
|
result.columns,
|
||||||
result.values,
|
result.values,
|
||||||
)[0] as Settings;
|
)[0] as Settings;
|
||||||
|
|
||||||
// Debug: Check the actual data types from SQLite
|
// Debug: Check the actual data types from SQLite
|
||||||
logConsoleAndDb(
|
logConsoleAndDb(
|
||||||
`[DEBUG] Raw SQLite data types for ${defaultSettings.activeDid}:`,
|
`[DEBUG] Raw SQLite data types for ${defaultSettings.activeDid}:`,
|
||||||
@@ -147,7 +147,7 @@ export async function retrieveSettingsForActiveAccount(): Promise<Settings> {
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const overrideSettingsFiltered = Object.fromEntries(
|
const overrideSettingsFiltered = Object.fromEntries(
|
||||||
Object.entries(overrideSettings).filter(([_, v]) => v !== null),
|
Object.entries(overrideSettings).filter(([_, v]) => v !== null),
|
||||||
);
|
);
|
||||||
@@ -339,12 +339,15 @@ export function mapColumnsToValues(
|
|||||||
export async function debugSettingsData(did?: string): Promise<void> {
|
export async function debugSettingsData(did?: string): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const platform = PlatformServiceFactory.getInstance();
|
const platform = PlatformServiceFactory.getInstance();
|
||||||
|
|
||||||
// Get all settings records
|
// Get all settings records
|
||||||
const allSettings = await platform.dbQuery("SELECT * FROM settings");
|
const allSettings = await platform.dbQuery("SELECT * FROM settings");
|
||||||
|
|
||||||
logConsoleAndDb(`[DEBUG] Total settings records: ${allSettings?.values?.length || 0}`, false);
|
logConsoleAndDb(
|
||||||
|
`[DEBUG] Total settings records: ${allSettings?.values?.length || 0}`,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
if (allSettings?.values?.length) {
|
if (allSettings?.values?.length) {
|
||||||
allSettings.values.forEach((row, index) => {
|
allSettings.values.forEach((row, index) => {
|
||||||
const settings = mapColumnsToValues(allSettings.columns, [row])[0];
|
const settings = mapColumnsToValues(allSettings.columns, [row])[0];
|
||||||
@@ -352,30 +355,50 @@ export async function debugSettingsData(did?: string): Promise<void> {
|
|||||||
logConsoleAndDb(`[DEBUG] - ID: ${settings.id}`, false);
|
logConsoleAndDb(`[DEBUG] - ID: ${settings.id}`, false);
|
||||||
logConsoleAndDb(`[DEBUG] - accountDid: ${settings.accountDid}`, false);
|
logConsoleAndDb(`[DEBUG] - accountDid: ${settings.accountDid}`, false);
|
||||||
logConsoleAndDb(`[DEBUG] - activeDid: ${settings.activeDid}`, false);
|
logConsoleAndDb(`[DEBUG] - activeDid: ${settings.activeDid}`, false);
|
||||||
|
|
||||||
if (settings.searchBoxes) {
|
if (settings.searchBoxes) {
|
||||||
logConsoleAndDb(`[DEBUG] - searchBoxes type: ${typeof settings.searchBoxes}`, false);
|
logConsoleAndDb(
|
||||||
logConsoleAndDb(`[DEBUG] - searchBoxes value: ${String(settings.searchBoxes)}`, false);
|
`[DEBUG] - searchBoxes type: ${typeof settings.searchBoxes}`,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
logConsoleAndDb(
|
||||||
|
`[DEBUG] - searchBoxes value: ${String(settings.searchBoxes)}`,
|
||||||
|
false,
|
||||||
|
);
|
||||||
|
|
||||||
// Try to parse it
|
// Try to parse it
|
||||||
try {
|
try {
|
||||||
const parsed = JSON.parse(String(settings.searchBoxes));
|
const parsed = JSON.parse(String(settings.searchBoxes));
|
||||||
logConsoleAndDb(`[DEBUG] - searchBoxes parsed successfully: ${JSON.stringify(parsed)}`, false);
|
logConsoleAndDb(
|
||||||
|
`[DEBUG] - searchBoxes parsed successfully: ${JSON.stringify(parsed)}`,
|
||||||
|
false,
|
||||||
|
);
|
||||||
} catch (parseError) {
|
} catch (parseError) {
|
||||||
logConsoleAndDb(`[DEBUG] - searchBoxes parse error: ${parseError}`, true);
|
logConsoleAndDb(
|
||||||
|
`[DEBUG] - searchBoxes parse error: ${parseError}`,
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logConsoleAndDb(`[DEBUG] - Full record: ${JSON.stringify(settings, null, 2)}`, false);
|
logConsoleAndDb(
|
||||||
|
`[DEBUG] - Full record: ${JSON.stringify(settings, null, 2)}`,
|
||||||
|
false,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// If specific DID provided, also check accounts table
|
// If specific DID provided, also check accounts table
|
||||||
if (did) {
|
if (did) {
|
||||||
const account = await platform.dbQuery("SELECT * FROM accounts WHERE did = ?", [did]);
|
const account = await platform.dbQuery(
|
||||||
logConsoleAndDb(`[DEBUG] Account for ${did}: ${JSON.stringify(account, null, 2)}`, false);
|
"SELECT * FROM accounts WHERE did = ?",
|
||||||
|
[did],
|
||||||
|
);
|
||||||
|
logConsoleAndDb(
|
||||||
|
`[DEBUG] Account for ${did}: ${JSON.stringify(account, null, 2)}`,
|
||||||
|
false,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logConsoleAndDb(`[DEBUG] Error inspecting settings data: ${error}`, true);
|
logConsoleAndDb(`[DEBUG] Error inspecting settings data: ${error}`, true);
|
||||||
}
|
}
|
||||||
@@ -386,47 +409,43 @@ export async function debugSettingsData(did?: string): Promise<void> {
|
|||||||
* Handles different SQLite implementations:
|
* Handles different SQLite implementations:
|
||||||
* - Web SQLite (wa-sqlite/absurd-sql): Auto-parses JSON strings to objects
|
* - Web SQLite (wa-sqlite/absurd-sql): Auto-parses JSON strings to objects
|
||||||
* - Capacitor SQLite: Returns raw strings that need manual parsing
|
* - Capacitor SQLite: Returns raw strings that need manual parsing
|
||||||
*
|
*
|
||||||
* @param value The value to parse (could be string or already parsed object)
|
* @param value The value to parse (could be string or already parsed object)
|
||||||
* @param defaultValue Default value if parsing fails
|
* @param defaultValue Default value if parsing fails
|
||||||
* @returns Parsed object or default value
|
* @returns Parsed object or default value
|
||||||
* @author Matthew Raymer
|
* @author Matthew Raymer
|
||||||
*/
|
*/
|
||||||
export function parseJsonField<T>(
|
export function parseJsonField<T>(value: unknown, defaultValue: T): T {
|
||||||
value: unknown,
|
|
||||||
defaultValue: T
|
|
||||||
): T {
|
|
||||||
try {
|
try {
|
||||||
// If already an object (web SQLite auto-parsed), return as-is
|
// If already an object (web SQLite auto-parsed), return as-is
|
||||||
if (typeof value === 'object' && value !== null) {
|
if (typeof value === "object" && value !== null) {
|
||||||
logConsoleAndDb(
|
logConsoleAndDb(
|
||||||
`[DEBUG] JSON field is already an object (auto-parsed by web SQLite), skipping parse`,
|
`[DEBUG] JSON field is already an object (auto-parsed by web SQLite), skipping parse`,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
return value as T;
|
return value as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's a string (Capacitor SQLite or fallback), parse it
|
// If it's a string (Capacitor SQLite or fallback), parse it
|
||||||
if (typeof value === 'string') {
|
if (typeof value === "string") {
|
||||||
logConsoleAndDb(
|
logConsoleAndDb(
|
||||||
`[DEBUG] JSON field is a string, parsing JSON (Capacitor SQLite or web fallback)`,
|
`[DEBUG] JSON field is a string, parsing JSON (Capacitor SQLite or web fallback)`,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
return JSON.parse(value) as T;
|
return JSON.parse(value) as T;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If it's null/undefined, return default
|
// If it's null/undefined, return default
|
||||||
if (value === null || value === undefined) {
|
if (value === null || value === undefined) {
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unexpected type, log and return default
|
// Unexpected type, log and return default
|
||||||
logConsoleAndDb(
|
logConsoleAndDb(
|
||||||
`[DEBUG] JSON field has unexpected type: ${typeof value}, returning default`,
|
`[DEBUG] JSON field has unexpected type: ${typeof value}, returning default`,
|
||||||
true,
|
true,
|
||||||
);
|
);
|
||||||
return defaultValue;
|
return defaultValue;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logConsoleAndDb(
|
logConsoleAndDb(
|
||||||
`[databaseUtil] Failed to parse JSON field: ${error}`,
|
`[databaseUtil] Failed to parse JSON field: ${error}`,
|
||||||
|
|||||||
@@ -735,7 +735,9 @@ export const generateSaveAndActivateIdentity = async (): Promise<string> => {
|
|||||||
const newId = newIdentifier(address, publicHex, privateHex, derivationPath);
|
const newId = newIdentifier(address, publicHex, privateHex, derivationPath);
|
||||||
|
|
||||||
await saveNewIdentity(newId, mnemonic, derivationPath);
|
await saveNewIdentity(newId, mnemonic, derivationPath);
|
||||||
await databaseUtil.updateDidSpecificSettings(newId.did, { isRegistered: false });
|
await databaseUtil.updateDidSpecificSettings(newId.did, {
|
||||||
|
isRegistered: false,
|
||||||
|
});
|
||||||
if (USE_DEXIE_DB) {
|
if (USE_DEXIE_DB) {
|
||||||
await updateAccountSettings(newId.did, { isRegistered: false });
|
await updateAccountSettings(newId.did, { isRegistered: false });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -145,7 +145,6 @@ import { db } from "../db/index";
|
|||||||
import { PlatformServiceFactory } from "../services/PlatformServiceFactory";
|
import { PlatformServiceFactory } from "../services/PlatformServiceFactory";
|
||||||
import { Contact, ContactMethod } from "../db/tables/contacts";
|
import { Contact, ContactMethod } from "../db/tables/contacts";
|
||||||
import { AppString } from "../constants/app";
|
import { AppString } from "../constants/app";
|
||||||
import { logger } from "../utils/logger";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contact Edit View Component
|
* Contact Edit View Component
|
||||||
|
|||||||
@@ -223,7 +223,6 @@ import {
|
|||||||
import { getContactJwtFromJwtUrl } from "../libs/crypto";
|
import { getContactJwtFromJwtUrl } from "../libs/crypto";
|
||||||
import { decodeEndorserJwt } from "../libs/crypto/vc";
|
import { decodeEndorserJwt } from "../libs/crypto/vc";
|
||||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||||
import { logger } from "../utils/logger";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface for contact data as stored in the database
|
* Interface for contact data as stored in the database
|
||||||
|
|||||||
@@ -475,7 +475,9 @@ export default class ContactQRScan extends Vue {
|
|||||||
|
|
||||||
// Add new contact
|
// Add new contact
|
||||||
// @ts-expect-error because we're just using the value to store to the DB
|
// @ts-expect-error because we're just using the value to store to the DB
|
||||||
contact.contactMethods = JSON.stringify(parseJsonField(contact.contactMethods, []));
|
contact.contactMethods = JSON.stringify(
|
||||||
|
parseJsonField(contact.contactMethods, []),
|
||||||
|
);
|
||||||
const { sql, params } = databaseUtil.generateInsertStatement(
|
const { sql, params } = databaseUtil.generateInsertStatement(
|
||||||
contact as unknown as Record<string, unknown>,
|
contact as unknown as Record<string, unknown>,
|
||||||
"contacts",
|
"contacts",
|
||||||
|
|||||||
@@ -779,7 +779,9 @@ export default class ContactQRScanShow extends Vue {
|
|||||||
|
|
||||||
// Add new contact
|
// Add new contact
|
||||||
// @ts-expect-error because we're just using the value to store to the DB
|
// @ts-expect-error because we're just using the value to store to the DB
|
||||||
contact.contactMethods = JSON.stringify(parseJsonField(contact.contactMethods, []));
|
contact.contactMethods = JSON.stringify(
|
||||||
|
parseJsonField(contact.contactMethods, []),
|
||||||
|
);
|
||||||
const { sql, params } = databaseUtil.generateInsertStatement(
|
const { sql, params } = databaseUtil.generateInsertStatement(
|
||||||
contact as unknown as Record<string, unknown>,
|
contact as unknown as Record<string, unknown>,
|
||||||
"contacts",
|
"contacts",
|
||||||
|
|||||||
@@ -103,8 +103,12 @@
|
|||||||
v-if="!showGiveNumbers"
|
v-if="!showGiveNumbers"
|
||||||
:class="
|
:class="
|
||||||
contactsSelected.length > 0
|
contactsSelected.length > 0
|
||||||
? 'text-md bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white ml-3 px-3 py-1.5 rounded-md cursor-pointer'
|
? 'text-md bg-gradient-to-b from-blue-400 to-blue-700 ' +
|
||||||
: 'text-md bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-slate-300 ml-3 px-3 py-1.5 rounded-md cursor-not-allowed'
|
'shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white ' +
|
||||||
|
'ml-3 px-3 py-1.5 rounded-md cursor-pointer'
|
||||||
|
: 'text-md bg-gradient-to-b from-slate-400 to-slate-700 ' +
|
||||||
|
'shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-slate-300 ' +
|
||||||
|
'ml-3 px-3 py-1.5 rounded-md cursor-not-allowed'
|
||||||
"
|
"
|
||||||
data-testId="copySelectedContactsButtonTop"
|
data-testId="copySelectedContactsButtonTop"
|
||||||
@click="copySelectedContacts()"
|
@click="copySelectedContacts()"
|
||||||
@@ -312,8 +316,12 @@
|
|||||||
v-if="!showGiveNumbers"
|
v-if="!showGiveNumbers"
|
||||||
:class="
|
:class="
|
||||||
contactsSelected.length > 0
|
contactsSelected.length > 0
|
||||||
? 'text-md bg-gradient-to-b from-blue-400 to-blue-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white ml-3 px-3 py-1.5 rounded-md cursor-pointer'
|
? 'text-md bg-gradient-to-b from-blue-400 to-blue-700 ' +
|
||||||
: 'text-md bg-gradient-to-b from-slate-400 to-slate-700 shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-slate-300 ml-3 px-3 py-1.5 rounded-md cursor-not-allowed'
|
'shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-white ' +
|
||||||
|
'ml-3 px-3 py-1.5 rounded-md cursor-pointer'
|
||||||
|
: 'text-md bg-gradient-to-b from-slate-400 to-slate-700 ' +
|
||||||
|
'shadow-[inset_0_-1px_0_0_rgba(0,0,0,0.5)] text-slate-300 ' +
|
||||||
|
'ml-3 px-3 py-1.5 rounded-md cursor-not-allowed'
|
||||||
"
|
"
|
||||||
@click="copySelectedContacts()"
|
@click="copySelectedContacts()"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -215,7 +215,7 @@ export default class SearchAreaView extends Vue {
|
|||||||
if (USE_DEXIE_DB) {
|
if (USE_DEXIE_DB) {
|
||||||
await db.open();
|
await db.open();
|
||||||
await db.settings.update(MASTER_SETTINGS_KEY, {
|
await db.settings.update(MASTER_SETTINGS_KEY, {
|
||||||
searchBoxes: searchBoxes as any, // Type assertion for Dexie compatibility
|
searchBoxes: searchBoxes as unknown, // Type assertion for Dexie compatibility
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
this.searchBox = newSearchBox;
|
this.searchBox = newSearchBox;
|
||||||
@@ -269,7 +269,7 @@ export default class SearchAreaView extends Vue {
|
|||||||
if (USE_DEXIE_DB) {
|
if (USE_DEXIE_DB) {
|
||||||
await db.open();
|
await db.open();
|
||||||
await db.settings.update(MASTER_SETTINGS_KEY, {
|
await db.settings.update(MASTER_SETTINGS_KEY, {
|
||||||
searchBoxes: "[]" as any, // Type assertion for Dexie compatibility
|
searchBoxes: "[]" as unknown as string, // Type assertion for Dexie compatibility
|
||||||
filterFeedByNearby: false,
|
filterFeedByNearby: false,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user