mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
Prompt user to save preset changes before they compute weights
Closes #2797
This commit is contained in:
parent
235b6aa2e4
commit
e0d2866f79
3 changed files with 21 additions and 1 deletions
|
@ -388,7 +388,7 @@ deck-config-compute-optimal-retention-tooltip =
|
|||
if it significantly differs from 0.9, it's a sign that the time you've allocated each day is either too low
|
||||
or too high for the amount of cards you're trying to learn. This number can be useful as a reference, but it
|
||||
is not recommended to copy it into the desired retention field.
|
||||
|
||||
deck-config-please-save-your-changes-first = Please save your changes first.
|
||||
deck-config-wait-for-audio = Wait for audio
|
||||
deck-config-show-reminder = Show Reminder
|
||||
deck-config-answer-again = Answer Again
|
||||
|
|
|
@ -63,6 +63,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
await setWantsAbort({});
|
||||
return;
|
||||
}
|
||||
if (state.presetAssignmentsChanged()) {
|
||||
alert(tr.deckConfigPleaseSaveYourChangesFirst());
|
||||
return;
|
||||
}
|
||||
computingWeights = true;
|
||||
try {
|
||||
await runWithBackendProgress(
|
||||
|
@ -97,6 +101,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
await setWantsAbort({});
|
||||
return;
|
||||
}
|
||||
if (state.presetAssignmentsChanged()) {
|
||||
alert(tr.deckConfigPleaseSaveYourChangesFirst());
|
||||
return;
|
||||
}
|
||||
checkingWeights = true;
|
||||
try {
|
||||
await runWithBackendProgress(
|
||||
|
@ -137,6 +145,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|||
await setWantsAbort({});
|
||||
return;
|
||||
}
|
||||
if (state.presetAssignmentsChanged()) {
|
||||
alert(tr.deckConfigPleaseSaveYourChangesFirst());
|
||||
return;
|
||||
}
|
||||
computingRetention = true;
|
||||
try {
|
||||
await runWithBackendProgress(
|
||||
|
|
|
@ -51,6 +51,7 @@ export class DeckOptionsState {
|
|||
private modifiedConfigs: Set<DeckOptionsId> = new Set();
|
||||
private removedConfigs: DeckOptionsId[] = [];
|
||||
private schemaModified: boolean;
|
||||
private _presetAssignmentsChanged = false;
|
||||
|
||||
constructor(targetDeckId: DeckOptionsId, data: DeckConfigsForUpdate) {
|
||||
this.targetDeckId = targetDeckId;
|
||||
|
@ -98,6 +99,7 @@ export class DeckOptionsState {
|
|||
|
||||
setCurrentIndex(index: number): void {
|
||||
this.selectedIdx = index;
|
||||
this._presetAssignmentsChanged = true;
|
||||
this.updateCurrentConfig();
|
||||
// use counts have changed
|
||||
this.updateConfigList();
|
||||
|
@ -142,6 +144,7 @@ export class DeckOptionsState {
|
|||
const configWithCount = { config, useCount: 0 };
|
||||
this.configs.push(configWithCount);
|
||||
this.selectedIdx = this.configs.length - 1;
|
||||
this._presetAssignmentsChanged = true;
|
||||
this.sortConfigs();
|
||||
this.updateCurrentConfig();
|
||||
this.updateConfigList();
|
||||
|
@ -167,6 +170,7 @@ export class DeckOptionsState {
|
|||
}
|
||||
this.configs.splice(this.selectedIdx, 1);
|
||||
this.selectedIdx = Math.max(0, this.selectedIdx - 1);
|
||||
this._presetAssignmentsChanged = true;
|
||||
this.updateCurrentConfig();
|
||||
this.updateConfigList();
|
||||
}
|
||||
|
@ -199,6 +203,10 @@ export class DeckOptionsState {
|
|||
};
|
||||
}
|
||||
|
||||
presetAssignmentsChanged(): boolean {
|
||||
return this._presetAssignmentsChanged;
|
||||
}
|
||||
|
||||
async save(applyToChildren: boolean): Promise<void> {
|
||||
await updateDeckConfigs(
|
||||
this.dataForSaving(applyToChildren),
|
||||
|
|
Loading…
Reference in a new issue