Use null
for unset cardId
This commit is contained in:
parent
dc4f5adc44
commit
8eed005db6
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import json
|
||||||
from typing import Callable
|
from typing import Callable
|
||||||
|
|
||||||
import aqt
|
import aqt
|
||||||
@ -69,8 +70,9 @@ class CardInfoDialog(QDialog):
|
|||||||
self.update_card(card_id)
|
self.update_card(card_id)
|
||||||
|
|
||||||
def update_card(self, card_id: CardId | None) -> None:
|
def update_card(self, card_id: CardId | None) -> None:
|
||||||
val = "undefined" if card_id is None else card_id
|
self.web.eval(
|
||||||
self.web.eval(f"cardInfo.then((c) => c.$set({{ cardId: {val} }}));")
|
f"cardInfo.then((c) => c.$set({{ cardId: {json.dumps(card_id)} }}));"
|
||||||
|
)
|
||||||
|
|
||||||
def reject(self) -> None:
|
def reject(self) -> None:
|
||||||
if self._on_close:
|
if self._on_close:
|
||||||
|
@ -9,12 +9,12 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||||||
import CardStats from "./CardStats.svelte";
|
import CardStats from "./CardStats.svelte";
|
||||||
import Revlog from "./Revlog.svelte";
|
import Revlog from "./Revlog.svelte";
|
||||||
|
|
||||||
export let cardId: number | undefined = undefined;
|
export let cardId: number | null = null;
|
||||||
export let includeRevlog: boolean = true;
|
export let includeRevlog: boolean = true;
|
||||||
|
|
||||||
let stats: Stats.CardStatsResponse | undefined;
|
let stats: Stats.CardStatsResponse | undefined;
|
||||||
|
|
||||||
$: if (cardId === undefined) {
|
$: if (cardId === null) {
|
||||||
stats = undefined;
|
stats = undefined;
|
||||||
} else {
|
} else {
|
||||||
const sentCardId = cardId;
|
const sentCardId = cardId;
|
||||||
|
Loading…
Reference in New Issue
Block a user