time-to-leave icon indicating copy to clipboard operation
time-to-leave copied to clipboard

Online Sync feature between devices

Open araujoarthur0 opened this issue 2 years ago • 11 comments

It would be awesome to have a feature to sync the database from more than one device with TTL installed. For example, travel with a notebook and load up the data from your home desktop, punch your time, then arrive back home and have the new data synched back to your desktop. We could do this through some web service integration, like Google Drive, as I have seen some Android Apps do, or Dropbox.

araujoarthur0 avatar Nov 23 '22 22:11 araujoarthur0

Would be great, and you mean the user itself would choose his cloud environment to save it, so we wouldn't have to maintain ourselves, right?

tupaschoal avatar Nov 24 '22 12:11 tupaschoal

Yes! We could add one service, and open for Hacktoberfest for new services hauahah

araujoarthur0 avatar Nov 24 '22 12:11 araujoarthur0

I would like to give this a try. I would do some research on how this could be implemented, then propose some ideas to you, and then we could decide how to proceed? I will try to work with Google Drive first

@araujoarthur0 could you specify the sources where you have seen this feature before?

SarahRemus avatar Nov 28 '22 16:11 SarahRemus

That would be awesome 🎉 I've seen this in WhatsApp and Tachiyomi apps, which backup to Google drive. It probably only needs read/write access to a service and then we always use a same folder. It could possibly be good to encrypt/compress the file to avoid unintentional tampering.

araujoarthur0 avatar Nov 28 '22 16:11 araujoarthur0

I think Tachiyomi is open source.

araujoarthur0 avatar Nov 28 '22 16:11 araujoarthur0

So the basic functionality of uploading data to Google Drive and importing it again is working. You can see my working branch here if you want to have a look at my code.

To create the credentials for TTL to work with the Google Drive Api these steps have to be followed. For my local development I created these credentials with my Google Account, but for the 'official version' I think it's better if one of the maintainers creates these credentials.

My Question: At the moment, the name of the file that is imported from Google Drive is hard-coded, as I'm not sure how to get the input for that from the user. Should I just create a window where the user puts in the file name & path it has in the drive? I also discovered the Google Picker API that lets you access files on Google Drive, so the user could choose the file he wants to upload. Or implement text input first and Google Picker in a future PR?

SarahRemus avatar Dec 12 '22 15:12 SarahRemus

Awesome, thanks Sarah! We'll ask @thamara to use her credentials later, or maybe we'll work towards a TTL email as well.

I think you can just do it hardcoded for now, and we can enjoy the picker api later. Getting the basics working first. The file itself will need to have a header/descriptor indicating it's a TTL file, so we can allow any file to be picked so long as we validate it.

Since this is a big feature, and @tupaschoal was considering doing a December release, I created the 'sync' parallel dev branch to 'main'. We can push the changes here piece by piece and later do the merge.

araujoarthur0 avatar Dec 12 '22 21:12 araujoarthur0

Okay, so I will focus on the main functionality for now and add more functionalities in future PRs.

Working on a dev branch is a great idea, that way I can do PRs for intermediate steps.

What do you mean by header/descriptor? An additional entry in the JSON file?

SarahRemus avatar Dec 13 '22 09:12 SarahRemus

What do you mean by header/descriptor? An additional entry in the JSON file?

I'm thinking of some kind of encryption key that uniquely identifies the app and its files. But that can also be for later. But our json probably needs a schema for validation.

araujoarthur0 avatar Dec 24 '22 13:12 araujoarthur0

I'm wondering how you @araujoarthur0 handle errors in general? With the API calls to the Google Drive API there are various things that could go wrong, should I display detailed messages to the user? Like the authentication failed, no file with this name exists, etc.? Should the errors be logged to the console or somewhere else?

SarahRemus avatar Jan 03 '23 14:01 SarahRemus

I believe some of them could be useful for the user to see and take action, like authentication issues. For those it's ok to trigger a dialog with the error contents. If we have a list of possible errors, it'll be good to offer alternative solutions for those that can be fixed.

araujoarthur0 avatar Jan 03 '23 14:01 araujoarthur0