mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Move update logic into CardInfo.svelte
Also use a simpler and faster way to avoid race conditions.
This commit is contained in:
parent
5062024974
commit
3c5e149176
1 changed files with 10 additions and 9 deletions
|
@ -13,17 +13,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
export let includeRevlog: boolean | undefined = undefined;
|
||||
|
||||
let stats: Stats.CardStatsResponse | undefined = undefined;
|
||||
let _updatingQueue: Promise<void> = Promise.resolve();
|
||||
|
||||
$: _updatingQueue = _updatingQueue.then(() => {
|
||||
if (cardId === undefined) {
|
||||
stats = undefined;
|
||||
} else {
|
||||
getCardStats(cardId).then((s) => {
|
||||
$: if (cardId === undefined) {
|
||||
stats = undefined;
|
||||
} else {
|
||||
const sentCardId = cardId;
|
||||
getCardStats(sentCardId).then((s) => {
|
||||
/* Skip if another update has been triggered in the meantime. */
|
||||
if (sentCardId === cardId) {
|
||||
stats = s;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="container">
|
||||
|
|
Loading…
Reference in a new issue