mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12:21 -04:00
Fix congrats screen not refreshing (#3594)
This commit is contained in:
parent
9a013d8601
commit
2cd6b1c3b7
2 changed files with 16 additions and 13 deletions
|
@ -4,6 +4,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
-->
|
-->
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type { CongratsInfoResponse } from "@generated/anki/scheduler_pb";
|
import type { CongratsInfoResponse } from "@generated/anki/scheduler_pb";
|
||||||
|
import { congratsInfo } from "@generated/backend";
|
||||||
import * as tr from "@generated/ftl";
|
import * as tr from "@generated/ftl";
|
||||||
import { bridgeLink } from "@tslib/bridgecommand";
|
import { bridgeLink } from "@tslib/bridgecommand";
|
||||||
|
|
||||||
|
@ -11,8 +12,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
import Container from "$lib/components/Container.svelte";
|
import Container from "$lib/components/Container.svelte";
|
||||||
|
|
||||||
import { buildNextLearnMsg } from "./lib";
|
import { buildNextLearnMsg } from "./lib";
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
|
||||||
export let info: CongratsInfoResponse;
|
export let info: CongratsInfoResponse;
|
||||||
|
export let refreshPeriodically = true;
|
||||||
|
|
||||||
const congrats = tr.schedulingCongratulationsFinished();
|
const congrats = tr.schedulingCongratulationsFinished();
|
||||||
let nextLearnMsg: string;
|
let nextLearnMsg: string;
|
||||||
|
@ -26,6 +29,18 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
const customStudyMsg = tr.schedulingHowToCustomStudy({
|
const customStudyMsg = tr.schedulingHowToCustomStudy({
|
||||||
customStudy,
|
customStudy,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
if (refreshPeriodically) {
|
||||||
|
setInterval(async () => {
|
||||||
|
try {
|
||||||
|
info = await congratsInfo({});
|
||||||
|
} catch {
|
||||||
|
console.log("congrats fetch failed");
|
||||||
|
}
|
||||||
|
}, 60000);
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Container --gutter-block="1rem" --gutter-inline="2px" breakpoint="sm">
|
<Container --gutter-block="1rem" --gutter-inline="2px" breakpoint="sm">
|
||||||
|
|
|
@ -20,21 +20,9 @@ export async function setupCongrats(): Promise<CongratsPage> {
|
||||||
const page = new CongratsPage({
|
const page = new CongratsPage({
|
||||||
// use #congrats if it exists, otherwise entire body
|
// use #congrats if it exists, otherwise entire body
|
||||||
target: customMountPoint ?? document.body,
|
target: customMountPoint ?? document.body,
|
||||||
props: { info },
|
props: { info, refreshPeriodically: !customMountPoint },
|
||||||
});
|
});
|
||||||
|
|
||||||
// refresh automatically if a custom area not provided
|
|
||||||
if (!customMountPoint) {
|
|
||||||
setInterval(async () => {
|
|
||||||
try {
|
|
||||||
const info = await congratsInfo({});
|
|
||||||
page.$set({ info });
|
|
||||||
} catch {
|
|
||||||
console.log("congrats fetch failed");
|
|
||||||
}
|
|
||||||
}, 60000);
|
|
||||||
}
|
|
||||||
|
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue