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:
Matthew Raymer
2025-08-07 01:49:22 +00:00
parent 4480778a49
commit b267d1bc66
2 changed files with 32 additions and 10 deletions

View File

@@ -7,7 +7,7 @@ import { useClipboard } from "@vueuse/core";
import { DEFAULT_PUSH_SERVER, NotificationIface } from "../constants/app";
import { Account, AccountEncrypted } from "../db/tables/accounts";
import { Contact, ContactWithJsonStrings } from "../db/tables/contacts";
import { Contact } from "../db/tables/contacts";
import { DEFAULT_PASSKEY_EXPIRATION_MINUTES } from "../db/tables/settings";
import {
arrayBufferToBase64,
@@ -902,13 +902,19 @@ export interface DatabaseExport {
export const contactsToExportJson = (contacts: Contact[]): DatabaseExport => {
// Convert each contact to a plain object and ensure all fields are included
const rows = contacts.map((contact) => {
const exContact: ContactWithJsonStrings = R.omit(
["contactMethods"],
contact,
);
exContact.contactMethods = contact.contactMethods
? JSON.stringify(contact.contactMethods)
: undefined;
// Create a plain object without stringifying contactMethods
const exContact = {
did: contact.did,
iViewContent: contact.iViewContent,
name: contact.name,
nextPubKeyHashB64: contact.nextPubKeyHashB64,
notes: contact.notes,
profileImageUrl: contact.profileImageUrl,
publicKeyBase64: contact.publicKeyBase64,
seesMe: contact.seesMe,
registered: contact.registered,
contactMethods: contact.contactMethods || [],
};
return exContact;
});