Add API endpoint to load a profile

If this needs tests please let me know
This commit is contained in:
Robert Sanek 2018-12-01 08:13:38 -08:00 committed by GitHub
parent aa7b277927
commit 8c3390106a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -507,6 +507,23 @@ class AnkiConnect:
return False
@api()
def loadProfile(self, name):
if not self.window().isVisible():
self.window().pm.load(name)
self.window().loadProfile()
self.window().profileDiag.closeWithoutQuitting()
return "Loaded profile {}.".format(name)
else:
cur_profile = self.window().pm.name
if cur_profile != name:
self.window().unloadProfileAndShowProfileManager()
self.loadProfile(name)
return "Switched from profile {} to profile {}.".format(cur_profile, name)
else:
return "Profile {} already loaded.".format(name)
@api()
def sync(self):
self.window().onSync()