mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -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;
|
export let includeRevlog: boolean | undefined = undefined;
|
||||||
|
|
||||||
let stats: Stats.CardStatsResponse | undefined = undefined;
|
let stats: Stats.CardStatsResponse | undefined = undefined;
|
||||||
let _updatingQueue: Promise<void> = Promise.resolve();
|
|
||||||
|
|
||||||
$: _updatingQueue = _updatingQueue.then(() => {
|
$: if (cardId === undefined) {
|
||||||
if (cardId === undefined) {
|
|
||||||
stats = undefined;
|
stats = undefined;
|
||||||
} else {
|
} else {
|
||||||
getCardStats(cardId).then((s) => {
|
const sentCardId = cardId;
|
||||||
|
getCardStats(sentCardId).then((s) => {
|
||||||
|
/* Skip if another update has been triggered in the meantime. */
|
||||||
|
if (sentCardId === cardId) {
|
||||||
stats = s;
|
stats = s;
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
Loading…
Reference in a new issue