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

Consider iCloud backup of snapshots #9

Open
efc opened this issue Feb 16, 2019 · 2 comments
Open

Consider iCloud backup of snapshots #9

efc opened this issue Feb 16, 2019 · 2 comments
Labels
enhancement New feature or request

Comments

@efc
Copy link
Member

efc commented Feb 16, 2019

This would require registering some sort of “listener” with the React app to get news of each storage (and deletion?) event and then reflecting those in iCloud. Each startup would also have to report all iCloud stored snapshots to the React app, where they could be reconciled with what is present there.

I think the current snapshot should never go to iCloud. That will be unique to each device. The iCloud backup will only affect saved snapshots.

What would be the impact of trashing a snapshot? Or of emptying the trash?

@efc efc added the enhancement New feature or request label Feb 16, 2019
@efc
Copy link
Member Author

efc commented Feb 16, 2019

This would also require some settings interface on the React side to opt in and out.

@alexclst
Copy link
Member

Here are some of my thoughts about how this could look...

With regard to settings

The React app would need to make a call to the Swift app (maybe subcalc://save-settings/{json}) that would cause Swift to parse the JSON and write to UserDefaults as well as, where appropriate, instance variables. Parsing would be needed since Swift needs to know natively if to do iCloud or not. The only settings that React needs to pass to Swift are those Swift needs (in this case, iCloud), the primary storage of settings should be in local storage managed by React.

When turning off iCloud it may be nice to offer the user a chance to keep or delete the saved snapshots that are on their device. This is much like what iOS does when signing out of iCloud.

For that matter, we’ll need to know if iCloud is even available, and only show the opt-in setting if the device is logged in to iCloud.

To send data to iCloud

When saving a snapshot the React app would need to send it to Swift (maybe subcalc://new-snapshot/{json}). Swift would record it as a new key-value item for iCloud. I think the iCloud storage appropriate for this is the Key-Value Store, nothing more complex.

Upon deleting a snapshot (is this with moving to the trash or when emptying the trash?) React would need to inform Swift of the identifiers (keys in iCloud key-value store) to remove. This could be something like subcalc://delete-snapshots/{json} where the JSON is an array of identifiers.

To read data from iCloud

The Swift app will be receiving updates from iCloud periodically and keeping track of changes. So, upon being asked to show the Open snapshot view Swift should send React the current saved snapshots (maybe in the app that menu item simply triggers subcalc://open-snapshots/). How exactly to do this, I’m not entirely sure. We could use the existing importQuery() method, but this reloads the React app. That would be fine if it is sensitive to incoming saved snapshots and knows to go to the Open snapshot view. But maybe there is a more fluid way of doing this.

In the end, while React stores saved snapshots in local storage, the true persistent store of saved snapshots will become iCloud, as maintained by the Swift app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants