Fix/Invalid memory states in simulator after parameters changed (#4317)

* Fix/Invalid memory states after optimization for simulator

* Update ts/routes/deck-options/FsrsOptions.svelte

* typo

* ./check
This commit is contained in:
Luc Mcgrady 2025-09-04 05:35:00 +01:00 committed by GitHub
parent 08431106da
commit dda730dfa2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View file

@ -498,6 +498,7 @@ deck-config-desired-retention-below-optimal = Your desired retention is below op
# cards that can be recalled or retrieved on a specific date. # cards that can be recalled or retrieved on a specific date.
deck-config-fsrs-simulator-experimental = FSRS Simulator (Experimental) deck-config-fsrs-simulator-experimental = FSRS Simulator (Experimental)
deck-config-fsrs-simulate-desired-retention-experimental = FSRS Desired Retention Simulator (Experimental) deck-config-fsrs-simulate-desired-retention-experimental = FSRS Desired Retention Simulator (Experimental)
deck-config-fsrs-simulate-save-preset = After optimizing, please save your config before running the simulator.
deck-config-fsrs-desired-retention-help-me-decide-experimental = Help Me Decide (Experimental) deck-config-fsrs-desired-retention-help-me-decide-experimental = Help Me Decide (Experimental)
deck-config-additional-new-cards-to-simulate = Additional new cards to simulate deck-config-additional-new-cards-to-simulate = Additional new cards to simulate
deck-config-simulate = Simulate deck-config-simulate = Simulate

View file

@ -53,6 +53,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
let desiredRetentionFocused = false; let desiredRetentionFocused = false;
let desiredRetentionEverFocused = false; let desiredRetentionEverFocused = false;
let optimized = false; let optimized = false;
const initialParams = [...fsrsParams($config)];
$: if (desiredRetentionFocused) { $: if (desiredRetentionFocused) {
desiredRetentionEverFocused = true; desiredRetentionEverFocused = true;
} }
@ -338,6 +339,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
state.save(UpdateDeckConfigsMode.COMPUTE_ALL_PARAMS); state.save(UpdateDeckConfigsMode.COMPUTE_ALL_PARAMS);
} }
function showSimulatorModal(modal: Modal) {
if (fsrsParams($config).toString() === initialParams.toString()) {
modal?.show();
} else {
alert(tr.deckConfigFsrsSimulateSavePreset());
}
}
let simulatorModal: Modal; let simulatorModal: Modal;
let workloadModal: Modal; let workloadModal: Modal;
</script> </script>
@ -368,7 +377,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
class="btn btn-primary" class="btn btn-primary"
on:click={() => { on:click={() => {
simulateFsrsRequest.reviewLimit = 9999; simulateFsrsRequest.reviewLimit = 9999;
workloadModal?.show(); showSimulatorModal(workloadModal);
}} }}
> >
{tr.deckConfigFsrsDesiredRetentionHelpMeDecideExperimental()} {tr.deckConfigFsrsDesiredRetentionHelpMeDecideExperimental()}
@ -455,7 +464,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
<hr /> <hr />
<div class="m-1"> <div class="m-1">
<button class="btn btn-primary" on:click={() => simulatorModal?.show()}> <button class="btn btn-primary" on:click={() => showSimulatorModal(simulatorModal)}>
{tr.deckConfigFsrsSimulatorExperimental()} {tr.deckConfigFsrsSimulatorExperimental()}
</button> </button>
</div> </div>