From d6ffaa921f2d9bf8111d1fcc67b8419be21b653f Mon Sep 17 00:00:00 2001 From: Luc Mcgrady Date: Mon, 9 Dec 2024 04:21:58 +0000 Subject: [PATCH] Add "No reviews to optimize" message (#3610) * Separate failed message from optimal * No reviews only * Fix: Can't block optimize if not optimal * Wording change * Update ftl/core/deck-config.ftl * Simplify code (dae) --- ftl/core/deck-config.ftl | 1 + ts/routes/deck-options/FsrsOptions.svelte | 13 +++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ftl/core/deck-config.ftl b/ftl/core/deck-config.ftl index c726cb5d1..15e87d776 100644 --- a/ftl/core/deck-config.ftl +++ b/ftl/core/deck-config.ftl @@ -452,6 +452,7 @@ deck-config-percent-of-reviews = deck-config-optimizing-preset = Optimizing preset { $current_count }/{ $total_count }... deck-config-fsrs-must-be-enabled = FSRS must be enabled first. deck-config-fsrs-params-optimal = The FSRS parameters currently appear to be optimal. +deck-config-fsrs-params-no-reviews = No reviews found. Please check that this preset is assigned to all decks you want to optimize (including subdecks) and try again. deck-config-wait-for-audio = Wait for audio deck-config-show-reminder = Show Reminder diff --git a/ts/routes/deck-options/FsrsOptions.svelte b/ts/routes/deck-options/FsrsOptions.svelte index 173ea8d51..921187716 100644 --- a/ts/routes/deck-options/FsrsOptions.svelte +++ b/ts/routes/deck-options/FsrsOptions.svelte @@ -148,14 +148,19 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html ignoreRevlogsBeforeMs: getIgnoreRevlogsBeforeMs(), currentParams: params, }); - if ( + + const already_optimal = (params.length && params.every( (n, i) => n.toFixed(4) === resp.params[i].toFixed(4), )) || - resp.params.length === 0 - ) { - setTimeout(() => alert(tr.deckConfigFsrsParamsOptimal()), 200); + resp.params.length === 0; + + if (already_optimal) { + const msg = resp.fsrsItems + ? tr.deckConfigFsrsParamsOptimal() + : tr.deckConfigFsrsParamsNoReviews(); + setTimeout(() => alert(msg), 200); } else { $config.fsrsParams5 = resp.params; }