Skip to content

Commit d28ae44

Browse files
authored
feat: added delay option for the review buttons (#1049)
* Added delay option for the review buttons * Fix localization * Revert indentation * Fix local fr, tr * Fix missing reviewButtonDelay
1 parent 6120be7 commit d28ae44

File tree

17 files changed

+92
-0
lines changed

17 files changed

+92
-0
lines changed

src/gui/flashcard-review-view.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { now } from "moment";
12
import { App, Notice, Platform, setIcon } from "obsidian";
23

34
import { RepItemScheduleInfo } from "src/algorithms/base/rep-item-schedule-info";
@@ -46,6 +47,7 @@ export class FlashcardReviewView {
4647
public goodButton: HTMLButtonElement;
4748
public easyButton: HTMLButtonElement;
4849
public answerButton: HTMLButtonElement;
50+
public lastPressed: number;
4951

5052
private chosenDeck: Deck | null;
5153
private reviewSequencer: IFlashcardReviewSequencer;
@@ -303,6 +305,15 @@ export class FlashcardReviewView {
303305
}
304306

305307
private _showAnswer(): void {
308+
const timeNow = now();
309+
if (
310+
this.lastPressed &&
311+
timeNow - this.lastPressed < this.plugin.data.settings.reviewButtonDelay
312+
) {
313+
return;
314+
}
315+
this.lastPressed = timeNow;
316+
306317
this.mode = FlashcardModalMode.Back;
307318

308319
this.resetButton.disabled = false;
@@ -357,6 +368,15 @@ export class FlashcardReviewView {
357368
}
358369

359370
private async _processReview(response: ReviewResponse): Promise<void> {
371+
const timeNow = now();
372+
if (
373+
this.lastPressed &&
374+
timeNow - this.lastPressed < this.plugin.data.settings.reviewButtonDelay
375+
) {
376+
return;
377+
}
378+
this.lastPressed = timeNow;
379+
360380
await this.reviewSequencer.processReview(response);
361381
await this._handleSkipCard();
362382
}

src/lang/locale/ar.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export default {
8181
FLASHCARD_EASY_DESC: '"تخصيص التسمية للزر "سهل',
8282
FLASHCARD_GOOD_DESC: '"تخصيص التسمية للزر "جيد',
8383
FLASHCARD_HARD_DESC: '"تخصيص التسمية للزر "صعب',
84+
REVIEW_BUTTON_DELAY: "Button press delay (ms)",
85+
REVIEW_BUTTON_DELAY_DESC:
86+
"Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.",
8487
FLASHCARD_TAGS: "وُسوم البطاقات",
8588
FLASHCARD_TAGS_DESC: "#2أدخل الوُسوم مفصولة بمسافات أو أسطر جديدة ، أي بطاقات# رزمة3# رزمة",
8689
CONVERT_FOLDERS_TO_DECKS: "تحويل المجلدات إلى ملفات أصلية و ملفات الفرعية؟",

src/lang/locale/cz.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export default {
8181
FLASHCARD_EASY_DESC: 'Customize the label for the "Easy" Button',
8282
FLASHCARD_GOOD_DESC: 'Customize the label for the "Good" Button',
8383
FLASHCARD_HARD_DESC: 'Customize the label for the "Hard" Button',
84+
REVIEW_BUTTON_DELAY: "Button press delay (ms)",
85+
REVIEW_BUTTON_DELAY_DESC:
86+
"Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.",
8487
FLASHCARD_TAGS: "Tag pro kartičky",
8588
FLASHCARD_TAGS_DESC:
8689
"Zadete tagy oodělené mezerou nebo odřádkováním například. #kartičky #balíčke2 #balíček3.",

src/lang/locale/de.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ export default {
8787
FLASHCARD_GOOD_DESC: 'Passe die Beschriftung für "Gut" Knopf an',
8888
FLASHCARD_EASY_DESC: 'Passe die Beschriftung für "Einfach" Knopf an',
8989
FLASHCARD_HARD_DESC: 'Passe die Beschriftung für "Schwer" Knopf an',
90+
REVIEW_BUTTON_DELAY: "Druckknopfverzögerung (ms)",
91+
REVIEW_BUTTON_DELAY_DESC:
92+
"Fügt den Überprüfungsschaltflächen („Einfach“, „Gut“, „Schwer“, „Antwort anzeigen“) eine Verzögerung hinzu, bevor sie erneut gedrückt werden können.",
9093
FLASHCARD_TAGS: "Lernkarten Tags",
9194
FLASHCARD_TAGS_DESC:
9295
"Mehrere Tags mit Leerzeichen oder Zeilenumbrüchen getrennt angeben. Bsp. #karte #stapel2 #stapel3.",

src/lang/locale/en.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export default {
8181
FLASHCARD_EASY_DESC: 'Customize the label for the "Easy" Button',
8282
FLASHCARD_GOOD_DESC: 'Customize the label for the "Good" Button',
8383
FLASHCARD_HARD_DESC: 'Customize the label for the "Hard" Button',
84+
REVIEW_BUTTON_DELAY: "Button press delay (ms)",
85+
REVIEW_BUTTON_DELAY_DESC:
86+
"Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.",
8487
FLASHCARD_TAGS: "Flashcard tags",
8588
FLASHCARD_TAGS_DESC:
8689
"Enter tags separated by spaces or newlines i.e. #flashcards #deck2 #deck3.",

src/lang/locale/es.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export default {
8181
FLASHCARD_EASY_DESC: "Personalize la etiqueta para el botón: Fácil",
8282
FLASHCARD_GOOD_DESC: "Personalize la etiqueta para el botón: Bien",
8383
FLASHCARD_HARD_DESC: "Personalize la etiqueta para el botón: Difícil",
84+
REVIEW_BUTTON_DELAY: "Button press delay (ms)",
85+
REVIEW_BUTTON_DELAY_DESC:
86+
"Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.",
8487
FLASHCARD_TAGS: "Etiquetas de las Tarjetas de Memorización",
8588
FLASHCARD_TAGS_DESC:
8689
"Escriba las etiquetas separadas por espacios o saltos de línea, por ejemplo, #memorizar #mazo2 #mazo3",

src/lang/locale/fr.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export default {
8282
FLASHCARD_EASY_DESC: "Changez le texte du bouton Facile",
8383
FLASHCARD_GOOD_DESC: "Changez le texte du bouton Correct",
8484
FLASHCARD_HARD_DESC: "Changez le texte du bouton Difficile",
85+
REVIEW_BUTTON_DELAY: "Button press delay (ms)",
86+
REVIEW_BUTTON_DELAY_DESC:
87+
"Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.",
8588
FLASHCARD_TAGS: "Tags des flashcards",
8689
FLASHCARD_TAGS_DESC:
8790
"Entrez les tags séparés par un espace ou une ligne i.e. #flashcards #paquet2 #paquet3.",

src/lang/locale/it.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export default {
8282
FLASHCARD_EASY_DESC: 'Personalizza il testo per il pulsante "Facile"',
8383
FLASHCARD_GOOD_DESC: 'Personalizza il testo per il pulsante "Buono"',
8484
FLASHCARD_HARD_DESC: 'Personalizza il testo per il pulsante "Difficile"',
85+
REVIEW_BUTTON_DELAY: "Button press delay (ms)",
86+
REVIEW_BUTTON_DELAY_DESC:
87+
"Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.",
8588
FLASHCARD_TAGS: "Etichette delle schede",
8689
FLASHCARD_TAGS_DESC:
8790
"Inserire etichette separate da spazi o a capi, per esempio #flashcards #deck2 #deck3.",

src/lang/locale/ja.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ export default {
8282
FLASHCARD_EASY_DESC: 'Customize the label for the "Easy" Button',
8383
FLASHCARD_GOOD_DESC: 'Customize the label for the "Good" Button',
8484
FLASHCARD_HARD_DESC: 'Customize the label for the "Hard" Button',
85+
REVIEW_BUTTON_DELAY: "Button press delay (ms)",
86+
REVIEW_BUTTON_DELAY_DESC:
87+
"Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.",
8588
FLASHCARD_TAGS: "フラッシュカードに使用するタグ",
8689
FLASHCARD_TAGS_DESC:
8790
'タグをスペースまたは改行で区切って入力してください。例: "#flashcards #deck2 #deck3"',

src/lang/locale/ko.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ export default {
8181
FLASHCARD_EASY_DESC: 'Customize the label for the "Easy" Button',
8282
FLASHCARD_GOOD_DESC: 'Customize the label for the "Good" Button',
8383
FLASHCARD_HARD_DESC: 'Customize the label for the "Hard" Button',
84+
REVIEW_BUTTON_DELAY: "Button press delay (ms)",
85+
REVIEW_BUTTON_DELAY_DESC:
86+
"Add a delay to the review buttons('Easy', 'Good', 'Hard', 'Show answer') before they could be pressed again.",
8487
FLASHCARD_TAGS: "플래시카드 태그",
8588
FLASHCARD_TAGS_DESC:
8689
"태그를 공백 또는 빈 줄로 구분해서 입력해주세요. 예) '#flashcards #deck2 #deck3'",

0 commit comments

Comments
 (0)