From 34809f2520674b33dc288c8e138cc4c48958e284 Mon Sep 17 00:00:00 2001 From: Jarrett Ye Date: Wed, 11 Sep 2024 00:15:33 +0800 Subject: [PATCH] Fix/simulator crashes if no history (#3405) * Fix/simulator crashes if no history * ./ninja format * remove (experimental) from ComputeOptimalRetention * update to fsrs-rs v1.2.2 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- cargo/licenses.json | 2 +- rslib/src/scheduler/fsrs/error.rs | 7 +++++++ ts/routes/deck-options/FsrsOptions.svelte | 4 ++-- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5fccf636b52..9643c9bfff2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1864,9 +1864,9 @@ dependencies = [ [[package]] name = "fsrs" -version = "1.2.0" +version = "1.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a6f86707f3588ae410917427aa986e8b281fd0fad96480afd150f3e694c0d76" +checksum = "1bbd56ab9e6c5d40802c7f73701b9cc4bccf9fa29037799a94ac9f1a94f1a5f7" dependencies = [ "burn", "itertools 0.12.1", diff --git a/Cargo.toml b/Cargo.toml index b2c7e8ff38a..513340be0fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,7 +35,7 @@ git = "https://github.com/ankitects/linkcheck.git" rev = "184b2ca50ed39ca43da13f0b830a463861adb9ca" [workspace.dependencies.fsrs] -version = "1.2.0" +version = "1.2.2" # git = "https://github.com/open-spaced-repetition/fsrs-rs.git" # rev = "58ca25ed2bc4bb1dc376208bbcaed7f5a501b941" # path = "../open-spaced-repetition/fsrs-rs" diff --git a/cargo/licenses.json b/cargo/licenses.json index 6cb62274c3b..cb676881725 100644 --- a/cargo/licenses.json +++ b/cargo/licenses.json @@ -1225,7 +1225,7 @@ }, { "name": "fsrs", - "version": "1.2.0", + "version": "1.2.2", "authors": "Open Spaced Repetition", "repository": "https://github.com/open-spaced-repetition/fsrs-rs", "license": "BSD-3-Clause", diff --git a/rslib/src/scheduler/fsrs/error.rs b/rslib/src/scheduler/fsrs/error.rs index 7edd2c9e0c4..5c9f030ee0c 100644 --- a/rslib/src/scheduler/fsrs/error.rs +++ b/rslib/src/scheduler/fsrs/error.rs @@ -20,6 +20,13 @@ impl From for AnkiError { backtrace: None, }, }, + FSRSError::InvalidDeckSize => AnkiError::InvalidInput { + source: InvalidInputError { + message: "no cards to simulate".to_string(), + source: None, + backtrace: None, + }, + }, } } } diff --git a/ts/routes/deck-options/FsrsOptions.svelte b/ts/routes/deck-options/FsrsOptions.svelte index 319095e3e7e..905f41c137c 100644 --- a/ts/routes/deck-options/FsrsOptions.svelte +++ b/ts/routes/deck-options/FsrsOptions.svelte @@ -319,8 +319,8 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html () => {}, ); } finally { + simulateProgressString = ""; if (resp) { - simulateProgressString = ""; const dailyTimeCost = movingAverage( resp.dailyTimeCost, Math.round(simulateFsrsRequest.daysToSimulate / 50), @@ -420,7 +420,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
- {tr.deckConfigComputeOptimalRetention()} (experimental) + {tr.deckConfigComputeOptimalRetention()}