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:
|
if self.id != 0:
|
||||||
self.col.backend.update_card(card)
|
self.col.backend.update_card(card)
|
||||||
else:
|
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:
|
def question(self, reload: bool = False, browser: bool = False) -> str:
|
||||||
return self.css() + self.render_output(reload, browser).question_text
|
return self.css() + self.render_output(reload, browser).question_text
|
||||||
|
|
|
@ -494,8 +494,9 @@ class RustBackend:
|
||||||
def update_card(self, card: BackendCard) -> None:
|
def update_card(self, card: BackendCard) -> None:
|
||||||
self._run_command(pb.BackendInput(update_card=card))
|
self._run_command(pb.BackendInput(update_card=card))
|
||||||
|
|
||||||
def add_card(self, card: BackendCard) -> None:
|
# returns the new card id
|
||||||
card.id = self._run_command(pb.BackendInput(add_card=card)).add_card
|
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]:
|
def get_deck_config(self, dcid: int) -> Dict[str, Any]:
|
||||||
jstr = self._run_command(pb.BackendInput(get_deck_config=dcid)).get_deck_config
|
jstr = self._run_command(pb.BackendInput(get_deck_config=dcid)).get_deck_config
|
||||||
|
|
Loading…
Reference in a new issue