Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move regions storage from UserDefaults to disk #629

Open
ualch9 opened this issue Jan 16, 2023 · 1 comment
Open

Move regions storage from UserDefaults to disk #629

ualch9 opened this issue Jan 16, 2023 · 1 comment

Comments

@ualch9
Copy link
Member

ualch9 commented Jan 16, 2023

Move regions storage from UserDefaults to disk. Storing regions in a database could be overkill since there are only a handful of infrequently-updated regions.

Currently, regions are stored as encoded objects in UserDefaults. We should use Codable to store OBA-regions in /Library/Application Support and custom regions in /Documents.

Files stored in /Documents in the app's sandbox are synced via iCloud and may be exposed via Files.app, which could be helpful for sharing custom regions.

The currently selected region would continue to be stored in UserDefaults, identified by its RegionIdentifier.

Possible file structure

Library/
  └ Application Support/       ☜ Won't be deleted by clearing cache, but won't be synced via iTunes/iCloud
    └ Regions/
      └ default-regions.json   ☜ This can be refreshed via OBA (not user-generated data)

Documents/
  └ custom-regions/            ☜ Any .json in the directory that can be decoded into a Region object.
    └ region-a.json
    └ region-b.json

Library/Application Support/Regions/default-regions.json is not a copy of regions.json, it's the encoded-JSON of how OBAKitCore.Region.


This change should not require an Internet migration, so we don't need to inform the user.

@aaryankotharii
Copy link

apologies I did not put up a message requesting permission.
I have solved this issue in PR #714. please have a look.
cc @ualch9 @aaronbrethorst

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants