Merge pull request #101 from z1lc/patch-1

Add API endpoint to load a profile
This commit is contained in:
Alex Yatskov 2018-12-01 19:53:24 -08:00 committed by GitHub
commit 3cb97f6023
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 40 additions and 0 deletions

View File

@ -507,6 +507,22 @@ class AnkiConnect:
return False
@api()
def loadProfile(self, name):
if name not in self.window().pm.profiles():
return False
if not self.window().isVisible():
self.window().pm.load(name)
self.window().loadProfile()
self.window().profileDiag.closeWithoutQuitting()
else:
cur_profile = self.window().pm.name
if cur_profile != name:
self.window().unloadProfileAndShowProfileManager()
self.loadProfile(name)
return True
@api()
def sync(self):
self.window().onSync()

View File

@ -213,6 +213,30 @@ guarantee that your application continues to function properly in the future.
}
```
* **loadProfile**
Selects the profile specified in request.
*Sample request*:
```json
{
"action": "loadProfile",
"params": {
"name": "user1"
},
"version": 6
}
```
*Sample result*:
```json
{
"result": true,
"error": null
}
```
* **multi**
Performs multiple actions in one request, returning an array with the response of each action (in the given order).