diff --git a/AnkiConnect.py b/AnkiConnect.py index 605dd21..c6bb2a4 100644 --- a/AnkiConnect.py +++ b/AnkiConnect.py @@ -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() diff --git a/README.md b/README.md index 37c154a..de3b6e7 100644 --- a/README.md +++ b/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** Performs multiple actions in one request, returning an array with the response of each action (in the given order).