-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathonFlush.py
40 lines (26 loc) · 950 Bytes
/
onFlush.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from anki.cards import Card
from anki.lang import _
from anki.notes import Note
from aqt.utils import askUser
from .config import getUserOption, setUserOption
from .rule import updateNote
def auto():
aut = getUserOption("Automatically applies rules", None)
if aut is None:
aut = askUser(_("""Do you want to automatically applies rules of the add-on "Trigger and actions"(1981494159) ? You can change your choice in the add-on configuration later.
See https://github.com/Arthur-Milchior/anki-trigger-action-on-note for more details."""), defaultno=True)
setUserOption("Automatically applies rules", aut)
return aut
oldFlushCard = Card.flush
def flushCard(self):
oldFlushCard(self)
if auto():
note = self.note()
updateNote(note)
Card.flush = flushCard
oldFlushNote = Note.flush
def flushNote(self):
oldFlushNote(self)
if auto():
updateNote(self)
Note.flush = flushNote