Open andrewsanchez opened 2 years ago
I'm not sure we need this right now.
From the current fields in the private config we only need to restore the data stored under the decks
key - the subscriptions of the user. It makes no sense to restore the token and username. However this should get implemented to not lock out users from their accounts: https://github.com/ankipalace/ankihub_addon/issues/148
{
"decks": {
"6d0038d5-6de1-437b-98d7-10161d55cfba": {
"anki_id": 1633196442423,
"creator": true,
"latest_update": "2022-07-21T12:20:11.828939+0000",
"name": "test"
},
"9bc5e5c6-2f08-4c19-b082-365c0ca34d1e": {
"anki_id": 1658065178810,
"creator": false,
"latest_update": "2022-07-18T08:00:31.610768+0000",
"name": "Neuroanatomy"
}
},
"token": "a699a9a32d654c496a805631ef82cc7e29286cf10a8562b797528812e4b62f90",
"user": "jakub1"
}
If a user re-installs the add-on after deleting it they would just have to re-add the decks they subscribed too.
The subscriptions could be restored with an endpoint like this:
URL: GET /api/decks/subscriptions/
Status Code: 200 OK
{
"subscriptions": [
"6d0038d5-6de1-437b-98d7-10161d55cfba": {
"creator": true,
"name": "test"
},
"9bc5e5c6-2f08-4c19-b082-365c0ca34d1e": {
"creator": false,
"name": "Neuroanatomy"
}
]
}
It could also just return a list of ankihub ids of decks without the extra information about them.
Then the add-on could just fetch data from this endpoint when logging in and check if there are subscriptions missing from the private config. It could then use https://github.com/ankipalace/ankihub_addon/blob/d87abb7395e447460451c9c0883883672455144f/ankihub/gui/decks.py#L218-L225 to reinstall all the missing decks and this will also add the decks to the private config.
This implementation has some caveats:
But for now it is very simple to implement. On the other hand users could just re-add the decks manually.
@andrewsanchez
if all they need to do is re-add decks using the add-on, that's great! let's just stick with that for now. I just need to make sure people know that.
capturing these kinds of documentation notes here for now.
if all they need to do is re-add decks using the add-on, that's great!
Yeah, but a requirement for that is that these issues are solved: https://github.com/ankipalace/ankihub_addon/issues/148 https://github.com/ankipalace/ankihub/issues/245
Because currently the user wouldn't be able to login after they delete the add-on.
Working on those.
If the user deletes and reinstalls the add-on, their private_config.json is gone. We need to be able to restore this based on API calls to AnkiHub.