mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
return the added card id instead of mutating the backend card object
This commit is contained in:
parent
431683aa5d
commit
03f9be21e9
2 changed files with 4 additions and 3 deletions
|
@ -106,7 +106,7 @@ class Card:
|
|||
if self.id != 0:
|
||||
self.col.backend.update_card(card)
|
||||
else:
|
||||
self.col.backend.add_card(card)
|
||||
self.id = self.col.backend.add_card(card)
|
||||
|
||||
def question(self, reload: bool = False, browser: bool = False) -> str:
|
||||
return self.css() + self.render_output(reload, browser).question_text
|
||||
|
|
|
@ -494,8 +494,9 @@ class RustBackend:
|
|||
def update_card(self, card: BackendCard) -> None:
|
||||
self._run_command(pb.BackendInput(update_card=card))
|
||||
|
||||
def add_card(self, card: BackendCard) -> None:
|
||||
card.id = self._run_command(pb.BackendInput(add_card=card)).add_card
|
||||
# returns the new card id
|
||||
def add_card(self, card: BackendCard) -> int:
|
||||
return self._run_command(pb.BackendInput(add_card=card)).add_card
|
||||
|
||||
def get_deck_config(self, dcid: int) -> Dict[str, Any]:
|
||||
jstr = self._run_command(pb.BackendInput(get_deck_config=dcid)).get_deck_config
|
||||
|
|
Loading…
Reference in a new issue