[x] If this PR alters the UI, I have attached pictures/videos
[x] This PR addresses one or more open issues that were assigned to me:
closes #1298
closes #1268
Pull Request Information
This PR makes Settings codable. This is accomplished through the intermediate CodableSettings struct; Settings should not be made directly codable because doing so results in AppStorage values being updated every time any Settings object is decoded. CodableSettings ultimately should replace Settings entirely, migrating our settings storage from AppStorage to JSON, but that's OOS here; this means that in the interim we do have the slightly awkward situation of duplicating default values between CodableSettings' decoder and Settings itself.
Some logic has been added to PersistenceRepository to save and retrieve settings files. There are two different locations settings files are stored:
System: these are app-generated settings files used for migration and persistence. From the code, they are identified by the SystemSetting enum.
User: these are user-generated settings files. Currently this system is not used, but the idea is to offer easily configurable and swappable settings profiles. These can then optionally be attached to accounts.
The new codable settings enable the following features:
Migrate from V1 settings
Save/Restore settings: "Save settings" saves the current settings state to System/v2. "Restore settings" reverts settings to that configuration.
Import/Export settings: allows users to directly import and export settings JSON files.
To test migration from v1 settings:
Reset settings state
Build and launch eric/v1-settings-cache
Change some settings
Close the app
Build and launch this branch
You should see a "Settings Restored" toast and any settings you changed in v1 should be preserved.
Checklist
Pull Request Information
This PR makes
Settings
codable. This is accomplished through the intermediateCodableSettings
struct;Settings
should not be made directly codable because doing so results inAppStorage
values being updated every time anySettings
object is decoded.CodableSettings
ultimately should replaceSettings
entirely, migrating our settings storage fromAppStorage
to JSON, but that's OOS here; this means that in the interim we do have the slightly awkward situation of duplicating default values betweenCodableSettings
' decoder andSettings
itself.Some logic has been added to
PersistenceRepository
to save and retrieve settings files. There are two different locations settings files are stored:SystemSetting
enum.The new codable settings enable the following features:
To test migration from v1 settings:
eric/v1-settings-cache
You should see a "Settings Restored" toast and any settings you changed in v1 should be preserved.