Add fix when decks have mids
This commit is contained in:
parent
fa98e0c324
commit
8328a0289d
@ -1038,6 +1038,7 @@ class AnkiConnect:
|
|||||||
raise Exception('deck was not found: {}'.format(note['deckName']))
|
raise Exception('deck was not found: {}'.format(note['deckName']))
|
||||||
|
|
||||||
self.collection().decks.select(deck['id'])
|
self.collection().decks.select(deck['id'])
|
||||||
|
savedMid = deck.pop('mid', None)
|
||||||
|
|
||||||
model = collection.models.byName(note['modelName'])
|
model = collection.models.byName(note['modelName'])
|
||||||
if model is None:
|
if model is None:
|
||||||
@ -1053,7 +1054,7 @@ class AnkiConnect:
|
|||||||
if type(closeAfterAdding) is not bool:
|
if type(closeAfterAdding) is not bool:
|
||||||
raise Exception('option parameter \'closeAfterAdding\' must be boolean')
|
raise Exception('option parameter \'closeAfterAdding\' must be boolean')
|
||||||
|
|
||||||
addCards = 'foobar'
|
addCards = None
|
||||||
|
|
||||||
if closeAfterAdding:
|
if closeAfterAdding:
|
||||||
|
|
||||||
@ -1105,6 +1106,9 @@ class AnkiConnect:
|
|||||||
aqt.dialogs._dialogs[windowName] = [AddCardsAndClose, None]
|
aqt.dialogs._dialogs[windowName] = [AddCardsAndClose, None]
|
||||||
addCards = aqt.dialogs.open(windowName, self.window())
|
addCards = aqt.dialogs.open(windowName, self.window())
|
||||||
|
|
||||||
|
if savedMid:
|
||||||
|
deck['mid'] = savedMid
|
||||||
|
|
||||||
editor = addCards.editor
|
editor = addCards.editor
|
||||||
ankiNote = editor.note
|
ankiNote = editor.note
|
||||||
|
|
||||||
@ -1130,6 +1134,9 @@ class AnkiConnect:
|
|||||||
def openNewWindow():
|
def openNewWindow():
|
||||||
addCards = aqt.dialogs.open('AddCards', self.window())
|
addCards = aqt.dialogs.open('AddCards', self.window())
|
||||||
|
|
||||||
|
if savedMid:
|
||||||
|
deck['mid'] = savedMid
|
||||||
|
|
||||||
editor = addCards.editor
|
editor = addCards.editor
|
||||||
ankiNote = editor.note
|
ankiNote = editor.note
|
||||||
|
|
||||||
@ -1152,7 +1159,11 @@ class AnkiConnect:
|
|||||||
addCards.setAndFocusNote(editor.note)
|
addCards.setAndFocusNote(editor.note)
|
||||||
|
|
||||||
if currentWindow is not None:
|
if currentWindow is not None:
|
||||||
currentWindow.closeWithCallback(openNewWindow)
|
if ANKI21:
|
||||||
|
currentWindow.closeWithCallback(openNewWindow)
|
||||||
|
else:
|
||||||
|
currentWindow.reject()
|
||||||
|
openNewWindow()
|
||||||
else:
|
else:
|
||||||
openNewWindow()
|
openNewWindow()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user