mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 22:12: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
|
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
|
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.
|
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-wait-for-audio = Wait for audio
|
||||||
deck-config-show-reminder = Show Reminder
|
deck-config-show-reminder = Show Reminder
|
||||||
deck-config-answer-again = Answer Again
|
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({});
|
await setWantsAbort({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (state.presetAssignmentsChanged()) {
|
||||||
|
alert(tr.deckConfigPleaseSaveYourChangesFirst());
|
||||||
|
return;
|
||||||
|
}
|
||||||
computingWeights = true;
|
computingWeights = true;
|
||||||
try {
|
try {
|
||||||
await runWithBackendProgress(
|
await runWithBackendProgress(
|
||||||
|
@ -97,6 +101,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
await setWantsAbort({});
|
await setWantsAbort({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (state.presetAssignmentsChanged()) {
|
||||||
|
alert(tr.deckConfigPleaseSaveYourChangesFirst());
|
||||||
|
return;
|
||||||
|
}
|
||||||
checkingWeights = true;
|
checkingWeights = true;
|
||||||
try {
|
try {
|
||||||
await runWithBackendProgress(
|
await runWithBackendProgress(
|
||||||
|
@ -137,6 +145,10 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
||||||
await setWantsAbort({});
|
await setWantsAbort({});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (state.presetAssignmentsChanged()) {
|
||||||
|
alert(tr.deckConfigPleaseSaveYourChangesFirst());
|
||||||
|
return;
|
||||||
|
}
|
||||||
computingRetention = true;
|
computingRetention = true;
|
||||||
try {
|
try {
|
||||||
await runWithBackendProgress(
|
await runWithBackendProgress(
|
||||||
|
|
|
@ -51,6 +51,7 @@ export class DeckOptionsState {
|
||||||
private modifiedConfigs: Set<DeckOptionsId> = new Set();
|
private modifiedConfigs: Set<DeckOptionsId> = new Set();
|
||||||
private removedConfigs: DeckOptionsId[] = [];
|
private removedConfigs: DeckOptionsId[] = [];
|
||||||
private schemaModified: boolean;
|
private schemaModified: boolean;
|
||||||
|
private _presetAssignmentsChanged = false;
|
||||||
|
|
||||||
constructor(targetDeckId: DeckOptionsId, data: DeckConfigsForUpdate) {
|
constructor(targetDeckId: DeckOptionsId, data: DeckConfigsForUpdate) {
|
||||||
this.targetDeckId = targetDeckId;
|
this.targetDeckId = targetDeckId;
|
||||||
|
@ -98,6 +99,7 @@ export class DeckOptionsState {
|
||||||
|
|
||||||
setCurrentIndex(index: number): void {
|
setCurrentIndex(index: number): void {
|
||||||
this.selectedIdx = index;
|
this.selectedIdx = index;
|
||||||
|
this._presetAssignmentsChanged = true;
|
||||||
this.updateCurrentConfig();
|
this.updateCurrentConfig();
|
||||||
// use counts have changed
|
// use counts have changed
|
||||||
this.updateConfigList();
|
this.updateConfigList();
|
||||||
|
@ -142,6 +144,7 @@ export class DeckOptionsState {
|
||||||
const configWithCount = { config, useCount: 0 };
|
const configWithCount = { config, useCount: 0 };
|
||||||
this.configs.push(configWithCount);
|
this.configs.push(configWithCount);
|
||||||
this.selectedIdx = this.configs.length - 1;
|
this.selectedIdx = this.configs.length - 1;
|
||||||
|
this._presetAssignmentsChanged = true;
|
||||||
this.sortConfigs();
|
this.sortConfigs();
|
||||||
this.updateCurrentConfig();
|
this.updateCurrentConfig();
|
||||||
this.updateConfigList();
|
this.updateConfigList();
|
||||||
|
@ -167,6 +170,7 @@ export class DeckOptionsState {
|
||||||
}
|
}
|
||||||
this.configs.splice(this.selectedIdx, 1);
|
this.configs.splice(this.selectedIdx, 1);
|
||||||
this.selectedIdx = Math.max(0, this.selectedIdx - 1);
|
this.selectedIdx = Math.max(0, this.selectedIdx - 1);
|
||||||
|
this._presetAssignmentsChanged = true;
|
||||||
this.updateCurrentConfig();
|
this.updateCurrentConfig();
|
||||||
this.updateConfigList();
|
this.updateConfigList();
|
||||||
}
|
}
|
||||||
|
@ -199,6 +203,10 @@ export class DeckOptionsState {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
presetAssignmentsChanged(): boolean {
|
||||||
|
return this._presetAssignmentsChanged;
|
||||||
|
}
|
||||||
|
|
||||||
async save(applyToChildren: boolean): Promise<void> {
|
async save(applyToChildren: boolean): Promise<void> {
|
||||||
await updateDeckConfigs(
|
await updateDeckConfigs(
|
||||||
this.dataForSaving(applyToChildren),
|
this.dataForSaving(applyToChildren),
|
||||||
|
|
Loading…
Reference in a new issue