* Added guiCheckDatabase action This action initiates a check database action in Anki but doesn’t wait for the action to complete before returning. * Fixed #202 no dconf attribute in saveDeckConfig Anki manages access to deck configuration differently now. This adapts saveDeckConfig to new style of access.
This commit is contained in:
parent
2150940c7e
commit
8404bd782d
20
README.md
20
README.md
@ -1230,6 +1230,26 @@ corresponding to when the API was available for use.
|
||||
}
|
||||
```
|
||||
|
||||
* **guiCheckDatabase**
|
||||
|
||||
Requests a database check, but returns immediately without waiting for the check to complete. Therefore, the action will always return `true` even if errors are detected during the database check.
|
||||
|
||||
*Sample request*:
|
||||
```json
|
||||
{
|
||||
"action": "guiCheckDatabase",
|
||||
"version": 6
|
||||
}
|
||||
```
|
||||
|
||||
*Sample result*:
|
||||
```json
|
||||
{
|
||||
"result": true,
|
||||
"error": null
|
||||
}
|
||||
```
|
||||
|
||||
#### Media Actions
|
||||
|
||||
* **storeMediaFile**
|
||||
|
@ -363,7 +363,7 @@ class AnkiConnect:
|
||||
return {
|
||||
"permission": "denied",
|
||||
}
|
||||
|
||||
|
||||
msg = QMessageBox(None)
|
||||
msg.setWindowTitle("A website want to access to Anki")
|
||||
msg.setText(origin + " request permission to use Anki through AnkiConnect.\nDo you want to give it access ?")
|
||||
@ -550,12 +550,13 @@ class AnkiConnect:
|
||||
config['id'] = str(config['id'])
|
||||
config['mod'] = anki.utils.intTime()
|
||||
config['usn'] = collection.usn()
|
||||
|
||||
if config['id'] not in collection.decks.dconf:
|
||||
if int(config['id']) not in [c['id'] for c in collection.decks.all_config()]:
|
||||
return False
|
||||
try:
|
||||
collection.decks.save(config)
|
||||
collection.decks.updateConf(config)
|
||||
except:
|
||||
return False
|
||||
|
||||
collection.decks.dconf[config['id']] = config
|
||||
collection.decks.changed = True
|
||||
return True
|
||||
|
||||
|
||||
@ -1088,14 +1089,14 @@ class AnkiConnect:
|
||||
checkForText = False
|
||||
if css and findText in model['css']:
|
||||
checkForText = True
|
||||
model['css'] = model['css'].replace(findText, replaceText)
|
||||
model['css'] = model['css'].replace(findText, replaceText)
|
||||
for tmpls in model.get('tmpls'):
|
||||
if front and findText in tmpls['qfmt']:
|
||||
checkForText = True
|
||||
tmpls['qfmt'] = tmpls['qfmt'].replace(findText, replaceText)
|
||||
if back and findText in tmpls['afmt']:
|
||||
checkForText = True
|
||||
tmpls['afmt'] = tmpls['afmt'].replace(findText, replaceText)
|
||||
tmpls['afmt'] = tmpls['afmt'].replace(findText, replaceText)
|
||||
self.collection().models.save(model, True)
|
||||
self.collection().models.flush()
|
||||
if checkForText:
|
||||
@ -1188,7 +1189,7 @@ class AnkiConnect:
|
||||
scids = anki.utils.ids2str(cards)
|
||||
self.collection().db.execute('update cards set type=3, queue=1 where id in ' + scids)
|
||||
self.stopEditing()
|
||||
|
||||
|
||||
|
||||
@util.api()
|
||||
def cardReviews(self, deck, startID):
|
||||
@ -1595,6 +1596,12 @@ class AnkiConnect:
|
||||
timer.start(1000) # 1s should be enough to allow the response to be sent.
|
||||
|
||||
|
||||
@util.api()
|
||||
def guiCheckDatabase(self):
|
||||
self.window().onCheckDB()
|
||||
return True
|
||||
|
||||
|
||||
@util.api()
|
||||
def addNotes(self, notes):
|
||||
results = []
|
||||
|
@ -62,6 +62,9 @@ class TestGui(unittest.TestCase):
|
||||
# guiDeckBrowser
|
||||
util.invoke('guiDeckBrowser')
|
||||
|
||||
# guiDatabaseCheck
|
||||
util.invoke('guiDatabaseCheck')
|
||||
|
||||
# guiExitAnki
|
||||
# util.invoke('guiExitAnki')
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user