fix: Convert searchBoxes arrays to JSON strings in $saveSettings and $updateSettings

- Add _convertSettingsForStorage helper method to handle Settings → SettingsWithJsonStrings conversion
- Fix $saveSettings and $saveUserSettings to properly convert searchBoxes arrays to JSON strings before database storage
- Update SearchAreaView.vue to use array format instead of manual JSON.stringify conversion
- Add comprehensive test UI in PlatformServiceMixinTest.vue with visual feedback and clear demonstration of conversion process
- Document migration strategy for consolidating $updateSettings into $saveSettings to reduce code duplication
- Add deprecation notices to $updateSettings method with clear migration guidance

The fix ensures that searchBoxes arrays are properly converted to JSON strings before database storage, preventing data corruption and maintaining consistency with the SettingsWithJsonStrings type definition. The enhanced test interface provides clear visualization of the conversion process and database storage format.

Migration Strategy:
- $saveSettings:  KEEP (will be primary method after consolidation)
- $updateSettings: ⚠️ DEPRECATED (will be removed in favor of $saveSettings)
- Future: Consolidate to single $saveSettings(changes, did?) method

Files changed:
- src/utils/PlatformServiceMixin.ts: Add conversion helper, fix save methods, add deprecation notices
- src/views/SearchAreaView.vue: Remove manual JSON conversion
- src/test/PlatformServiceMixinTest.vue: Add comprehensive test UI with highlighting
- docs/migration-templates/updateSettings-consolidation-plan.md: Document future consolidation strategy
This commit is contained in:
Matthew Raymer
2025-07-30 09:48:52 +00:00
parent 118e93b85a
commit 9067bec54a
4 changed files with 359 additions and 13 deletions

View File

@@ -310,10 +310,9 @@ export default class SearchAreaView extends Vue {
},
};
const searchBoxes = JSON.stringify([newSearchBox]);
// Store search box configuration using platform service
await this.$updateSettings({ searchBoxes: searchBoxes as any });
// searchBoxes will be automatically converted to JSON string by $updateSettings
await this.$updateSettings({ searchBoxes: [newSearchBox] });
this.searchBox = newSearchBox;
this.isChoosingSearchBox = false;
@@ -347,7 +346,7 @@ export default class SearchAreaView extends Vue {
try {
// Clear search box settings and disable nearby filtering
await this.$updateSettings({
searchBoxes: "[]" as any,
searchBoxes: [],
filterFeedByNearby: false,
});