Merge pull request #23 from fancy-flashcard/bug-fixes-#21-#22

Bug fixes #21 #22
This commit is contained in:
Niko Lockenvitz 2020-07-26 18:26:34 +02:00 committed by GitHub
commit 7af2eeb8a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 2 deletions

View file

@ -85,8 +85,13 @@ export default class Learn extends LearnProps {
this.moveToPrev();
});
}
destroyed() {
this.$eventHub.$off(Event.SWIPE_LEFT_IN_LEARN);
this.$eventHub.$off(Event.SWIPE_RIGHT_IN_LEARN);
}
updateCurLearningElement() {
if (!this.learningSessionManager) return;
this.curLearningElement = this.learningSessionManager.getCurrentLearningSessionElementWithCardDetails();
this.updateRatingForCurrentLearningElement();
saveLearningSessionManagerDataToLocalStorage(this.learningSessionManager);
@ -177,7 +182,9 @@ export default class Learn extends LearnProps {
}
finishSession() {
finishLearningDialog(this, this.getBarsForFinishLearningDialog());
finishLearningDialog(this, this.getBarsForFinishLearningDialog(), () => {
this.learningSessionManager = null;
});
}
getBarsForFinishLearningDialog(): CustomDialogOptionsBarChartBar[] {

View file

@ -9,7 +9,8 @@ import { clearLearningSessionManagerDataInLocalStorage } from "./learningSession
export function finishLearningDialog(
context: any,
bars: CustomDialogOptionsBarChartBar[]
bars: CustomDialogOptionsBarChartBar[],
callbackLearningFinished: { (): void }
) {
const options = {
title: "Finish Learning?",
@ -32,6 +33,7 @@ export function finishLearningDialog(
QuitLearningReason.NO_MORE_CARDS
);
clearLearningSessionManagerDataInLocalStorage();
callbackLearningFinished();
},
},
],