Update AnkiConnect.py

This commit is contained in:
Robert Sanek 2018-12-01 19:42:56 -08:00 committed by GitHub
parent 8c3390106a
commit 0fe61050c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -509,19 +509,18 @@ class AnkiConnect:
@api() @api()
def loadProfile(self, name): def loadProfile(self, name):
if name not in self.window().pm.profiles():
return False
if not self.window().isVisible(): if not self.window().isVisible():
self.window().pm.load(name) self.window().pm.load(name)
self.window().loadProfile() self.window().loadProfile()
self.window().profileDiag.closeWithoutQuitting() self.window().profileDiag.closeWithoutQuitting()
return "Loaded profile {}.".format(name)
else: else:
cur_profile = self.window().pm.name cur_profile = self.window().pm.name
if cur_profile != name: if cur_profile != name:
self.window().unloadProfileAndShowProfileManager() self.window().unloadProfileAndShowProfileManager()
self.loadProfile(name) self.loadProfile(name)
return "Switched from profile {} to profile {}.".format(cur_profile, name) return True
else:
return "Profile {} already loaded.".format(name)
@api() @api()