Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dda730d

Browse files
authored
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
1 parent 0843110 commit dda730d

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

ftl/core/deck-config.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ deck-config-desired-retention-below-optimal = Your desired retention is below op
498498
# cards that can be recalled or retrieved on a specific date.
499499
deck-config-fsrs-simulator-experimental = FSRS Simulator (Experimental)
500500
deck-config-fsrs-simulate-desired-retention-experimental = FSRS Desired Retention Simulator (Experimental)
501+
deck-config-fsrs-simulate-save-preset = After optimizing, please save your config before running the simulator.
501502
deck-config-fsrs-desired-retention-help-me-decide-experimental = Help Me Decide (Experimental)
502503
deck-config-additional-new-cards-to-simulate = Additional new cards to simulate
503504
deck-config-simulate = Simulate

ts/routes/deck-options/FsrsOptions.svelte

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
5353
let desiredRetentionFocused = false;
5454
let desiredRetentionEverFocused = false;
5555
let optimized = false;
56+
const initialParams = [...fsrsParams($config)];
5657
$: if (desiredRetentionFocused) {
5758
desiredRetentionEverFocused = true;
5859
}
@@ -338,6 +339,14 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
338339
state.save(UpdateDeckConfigsMode.COMPUTE_ALL_PARAMS);
339340
}
340341
342+
function showSimulatorModal(modal: Modal) {
343+
if (fsrsParams($config).toString() === initialParams.toString()) {
344+
modal?.show();
345+
} else {
346+
alert(tr.deckConfigFsrsSimulateSavePreset());
347+
}
348+
}
349+
341350
let simulatorModal: Modal;
342351
let workloadModal: Modal;
343352
</script>
@@ -368,7 +377,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
368377
class="btn btn-primary"
369378
on:click={() => {
370379
simulateFsrsRequest.reviewLimit = 9999;
371-
workloadModal?.show();
380+
showSimulatorModal(workloadModal);
372381
}}
373382
>
374383
{tr.deckConfigFsrsDesiredRetentionHelpMeDecideExperimental()}
@@ -455,7 +464,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
455464
<hr />
456465

457466
<div class="m-1">
458-
<button class="btn btn-primary" on:click={() => simulatorModal?.show()}>
467+
<button class="btn btn-primary" on:click={() => showSimulatorModal(simulatorModal)}>
459468
{tr.deckConfigFsrsSimulatorExperimental()}
460469
</button>
461470
</div>

0 commit comments

Comments
 (0)