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

Gamebook Library Cloud Backups #34

Open
amiantos opened this issue Apr 6, 2023 · 7 comments · May be fixed by #50
Open

Gamebook Library Cloud Backups #34

amiantos opened this issue Apr 6, 2023 · 7 comments · May be fixed by #50
Labels
accepted feature Feature that will be implemented
Milestone

Comments

@amiantos
Copy link
Owner

amiantos commented Apr 6, 2023

It would be nice if users could opt-in to storing their gamebook libraries securely in iCloud somehow. Maybe I can build something really simple like a mass export to a folder in iCloud. Or go all out and use CloudKit to store the Core Data DB in the cloud...? Maybe a little kooky but that would be the coolest.

It goes without saying it's important this cloud backup use iCloud for security and privacy purposes.

@amiantos
Copy link
Owner Author

I was curious how NetNewsWire handles iCloud syncing and it looks like it uses CloudKit https://github.com/Ranchero-Software/NetNewsWire/tree/main/Account/Sources/Account/CloudKit

Wonder if their implementation is the most straightforward way to implement CloudKit. Since GBE is already using core data in a fairly standard way, maybe using CloudKit for database syncing wouldn't be a big deal... only one way to find out I guess...

Docs: https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit

@amiantos amiantos added this to the 1.1 milestone Apr 11, 2023
@amiantos
Copy link
Owner Author

Doesn't look like the core data store in GBE has any problem with CloudKit requirements: https://developer.apple.com/documentation/coredata/mirroring_a_core_data_store_with_cloudkit/creating_a_core_data_model_for_cloudkit#3191035

@amiantos
Copy link
Owner Author

Doesn't seem like it would be all that difficult. And once the database gets into iCloud, we could write a web app.

Now, that said, users need to be able to opt-in to this, not opt-out, as I do promote the privacy and disconnectedness of Gamebook Engine. I assume I should be able to set it up that way.

@amiantos
Copy link
Owner Author

amiantos commented Apr 11, 2023

Got blocked trying to generate a CloudKit schema.

CloudKit integration does not support ordered relationships. The following relationships are marked ordered:
Game: pages
Page: decisions

CloudKit integration requires that all attributes be optional, or have a default value set. The following attributes are marked non-optional but do not have a default value:
Attribute: name
Attribute: uuid
Consequence: uuid
Decision: content
Decision: uuid
Game: name
Game: uuid
Page: content
Page: uuid
Rule: uuid

CloudKit integration requires that all relationships be optional, the following are not:
Attribute: game
Consequence: page
Decision: page
Page: game
Rule: decision

This might not be a big blocker. Pages don't need to be ordered in a game, literally no reason for that. And decisions... well... ordering seems like it might be important there though there is currently no way to actually reorder decisions on a page. If we want to keep ordered decisions, we can implement a displayOrder attribute easy enough.

"default value" is interesting, I wonder if default value can be an actual UUID in those cases. The other things have in-code defaults really.

And then the optional relationship thing... I mean... if an attribute doesn't have a game, if a consequence doesn't have a page, that's just bad data. But maybe it's not a big deal to consider those things optional.

Schema changes does mean migrations but maybe it's not a big deal...

@amiantos amiantos linked a pull request Apr 11, 2023 that will close this issue
@amiantos
Copy link
Owner Author

Another possibility is to set up a second core data store just to support syncing. Model would be super simple, local_uuid, game_json (the export of the game), sync_timestamp, and date_updated. I think with that we'd have enough to set up a decent document-based sync system.

@amiantos amiantos added accepted feature Feature that will be implemented and removed feature idea labels Apr 13, 2023
@amiantos
Copy link
Owner Author

This doesn't have to be the solution--because I quite like my last comment's idea of essentially a document store using CloudKit--but taking that idea even further, does it not seem like Gamebook Engine could be something a bit more like, say, Pages? A productivity app? In the sense that it's acting on files. The fact that I'm loading the games into a database on the device and playing them off of that is an implementation detail. In reality it would make more sense if gamebooks lived in a Gamebook Engine specific folder in your documents or on your phone some where and you used gamebook engine to open them.

But I guess that interface is kind of lame deep down. There's no reason it can't work that way, though.

In reality Gamebook Engine is more like Books.app, where you drag files into it and then it does some hoodoo and changes the files all up into something it likes more and creates a database and syncs it to the cloud in its own way and so on.

@amiantos
Copy link
Owner Author

Idea of a document store backup is winning in my mind. And it should be essentially one-way where by default your books are uploaded to the sync database whenever they change, but it's not an automatic two-way sync. You can choose to overwrite your local book store with what is in the cloud if you want, but it's not going to overwrite a game while you're playing it. I was really overthinking the issue for a bit there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted feature Feature that will be implemented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant