forked from trent_larson/crowd-funder-for-time-pwa
Fix contact backup export: contactMethods now exports as JSON arrays instead of strings
- Fixed contactsToExportJson to export contactMethods as proper arrays instead of stringified JSON - Added JSON parsing for contactMethods in _mapColumnsToValues when retrieving from database - Updated $insertContact to properly handle contactMethods field storage - Removed unused ContactWithJsonStrings import ref: https://app.clickup.com/t/86b63ffpb Resolves issue where contact backup exports showed contactMethods as "[]" strings instead of proper JSON arrays.
This commit is contained in:
@@ -246,6 +246,15 @@ export const PlatformServiceMixin = {
|
||||
// Keep null values as null
|
||||
}
|
||||
|
||||
// Handle JSON fields like contactMethods
|
||||
if (column === "contactMethods" && typeof value === "string") {
|
||||
try {
|
||||
value = JSON.parse(value);
|
||||
} catch {
|
||||
value = [];
|
||||
}
|
||||
}
|
||||
|
||||
obj[column] = value;
|
||||
});
|
||||
return obj;
|
||||
@@ -1051,12 +1060,18 @@ export const PlatformServiceMixin = {
|
||||
contact.profileImageUrl !== undefined
|
||||
? contact.profileImageUrl
|
||||
: null,
|
||||
contactMethods:
|
||||
contact.contactMethods !== undefined
|
||||
? (Array.isArray(contact.contactMethods)
|
||||
? JSON.stringify(contact.contactMethods)
|
||||
: contact.contactMethods)
|
||||
: null,
|
||||
};
|
||||
|
||||
await this.$dbExec(
|
||||
`INSERT OR REPLACE INTO contacts
|
||||
(did, name, publicKeyBase64, seesMe, registered, nextPubKeyHashB64, profileImageUrl)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?)`,
|
||||
(did, name, publicKeyBase64, seesMe, registered, nextPubKeyHashB64, profileImageUrl, contactMethods)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,
|
||||
[
|
||||
safeContact.did,
|
||||
safeContact.name,
|
||||
@@ -1065,6 +1080,7 @@ export const PlatformServiceMixin = {
|
||||
safeContact.registered,
|
||||
safeContact.nextPubKeyHashB64,
|
||||
safeContact.profileImageUrl,
|
||||
safeContact.contactMethods,
|
||||
],
|
||||
);
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user