fix: resolve cross-platform SQLite JSON parsing inconsistencies

- Add platform-agnostic parseJsonField utility to handle different SQLite implementations
- Web SQLite (wa-sqlite/absurd-sql) auto-parses JSON strings to objects
- Capacitor SQLite returns raw strings requiring manual parsing
- Update searchBoxes parsing to use new utility for consistent behavior
- Fixes "[object Object] is not valid JSON" error when switching platforms
- Ensures compatibility between web and mobile SQLite implementations

Fixes: searchBoxes parsing errors in databaseUtil.ts
Related: contactMethods field has similar issue (needs same treatment)
This commit is contained in:
Matthew Raymer
2025-06-11 03:44:28 +00:00
parent 6afe6f07f6
commit 3e81c9f44f
3 changed files with 628 additions and 399 deletions

View File

@@ -215,7 +215,7 @@ export default class SearchAreaView extends Vue {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
searchBoxes: [newSearchBox],
searchBoxes: searchBoxes as any, // Type assertion for Dexie compatibility
});
}
this.searchBox = newSearchBox;
@@ -269,7 +269,7 @@ export default class SearchAreaView extends Vue {
if (USE_DEXIE_DB) {
await db.open();
await db.settings.update(MASTER_SETTINGS_KEY, {
searchBoxes: [],
searchBoxes: "[]" as any, // Type assertion for Dexie compatibility
filterFeedByNearby: false,
});
}