Merge pull request #101 from z1lc/patch-1
Add API endpoint to load a profile
This commit is contained in:
commit
3cb97f6023
@ -507,6 +507,22 @@ class AnkiConnect:
|
|||||||
return False
|
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()
|
@api()
|
||||||
def sync(self):
|
def sync(self):
|
||||||
self.window().onSync()
|
self.window().onSync()
|
||||||
|
24
README.md
24
README.md
@ -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**
|
* **multi**
|
||||||
|
|
||||||
Performs multiple actions in one request, returning an array with the response of each action (in the given order).
|
Performs multiple actions in one request, returning an array with the response of each action (in the given order).
|
||||||
|
Loading…
Reference in New Issue
Block a user