forked from trent_larson/crowd-funder-for-time-pwa
fix: resolve cross-platform contactMethods JSON parsing inconsistencies
- Add platform-agnostic parseJsonField utility for contactMethods handling - Update contact export functions (contactsToExportJson, contactToCsvLine) - Fix contact storage in QR scan views (ContactQRScanShowView, ContactQRScanFullView) - Ensure consistent JSON string storage across web SQLite and Capacitor SQLite - Prevents "[object Object] is not valid JSON" errors when switching platforms - Maintains compatibility between auto-parsing web SQLite and raw string Capacitor SQLite Fixes: contactMethods parsing errors in export and QR scan functionality Related: searchBoxes field had similar issue (already fixed)
This commit is contained in:
@@ -138,11 +138,14 @@ import { RouteLocationNormalizedLoaded, Router } from "vue-router";
|
||||
|
||||
import QuickNav from "../components/QuickNav.vue";
|
||||
import TopMessage from "../components/TopMessage.vue";
|
||||
import { AppString, NotificationIface, USE_DEXIE_DB } from "../constants/app";
|
||||
import { db } from "../db/index";
|
||||
import { Contact, ContactMethod } from "../db/tables/contacts";
|
||||
import { NotificationIface, USE_DEXIE_DB } from "../constants/app";
|
||||
import * as databaseUtil from "../db/databaseUtil";
|
||||
import { PlatformServiceFactory } from "@/services/PlatformServiceFactory";
|
||||
import { parseJsonField } from "../db/databaseUtil";
|
||||
import { db } from "../db/index";
|
||||
import { PlatformServiceFactory } from "../services/PlatformServiceFactory";
|
||||
import { Contact, ContactMethod } from "../db/tables/contacts";
|
||||
import { AppString } from "../constants/app";
|
||||
import { logger } from "../utils/logger";
|
||||
|
||||
/**
|
||||
* Contact Edit View Component
|
||||
@@ -230,9 +233,7 @@ export default class ContactEditView extends Vue {
|
||||
let contact: Contact | undefined = databaseUtil.mapQueryResultToValues(
|
||||
dbContact,
|
||||
)[0] as unknown as Contact;
|
||||
contact.contactMethods = JSON.parse(
|
||||
(contact?.contactMethods as unknown as string) || "[]",
|
||||
);
|
||||
contact.contactMethods = parseJsonField(contact?.contactMethods, []);
|
||||
if (USE_DEXIE_DB) {
|
||||
await db.open();
|
||||
contact = await db.contacts.get(contactDid || "");
|
||||
|
||||
Reference in New Issue
Block a user