From deb55ee338269d51d001f1120cd8d0d6a2c4bc6a Mon Sep 17 00:00:00 2001 From: bobzel Date: Mon, 20 May 2024 14:18:41 -0400 Subject: lint fixes --- src/client/apis/gpt/GPT.ts | 2 +- .../views/collections/CollectionCarouselView.tsx | 54 +++++++++++----------- .../views/nodes/CollectionFreeFormDocumentView.tsx | 6 +-- 3 files changed, 30 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/client/apis/gpt/GPT.ts b/src/client/apis/gpt/GPT.ts index 9efe4ec39..cca9d58f3 100644 --- a/src/client/apis/gpt/GPT.ts +++ b/src/client/apis/gpt/GPT.ts @@ -64,7 +64,7 @@ let lastResp = ''; * @returns AI Output */ const gptAPICall = async (inputTextIn: string, callType: GPTCallType, prompt?: any) => { - const inputText = callType === GPTCallType.SUMMARY || callType == GPTCallType.FLASHCARD || GPTCallType.QUIZ ? inputTextIn + '.' : inputTextIn; + const inputText = [GPTCallType.SUMMARY, GPTCallType.FLASHCARD, GPTCallType.QUIZ].includes(callType) ? inputTextIn + '.' : inputTextIn; const opts: GPTCallOpts = callTypeMap[callType]; if (lastCall === inputText) return lastResp; try { diff --git a/src/client/views/collections/CollectionCarouselView.tsx b/src/client/views/collections/CollectionCarouselView.tsx index b736c7ced..95425a217 100644 --- a/src/client/views/collections/CollectionCarouselView.tsx +++ b/src/client/views/collections/CollectionCarouselView.tsx @@ -49,35 +49,35 @@ export class CollectionCarouselView extends CollectionSubView() { advance = (e: React.MouseEvent) => { e.stopPropagation(); this.layoutDoc._carousel_index = (NumCast(this.layoutDoc._carousel_index) + 1) % this.childLayoutPairs.length; - var startInd = this.layoutDoc._carousel_index; + let startInd = this.layoutDoc._carousel_index; // if the star filter is selected - if (this.layoutDoc[`filterOp`] == 'star') { + if (this.layoutDoc.filterOp === 'star') { // go to a flashcard that is starred, skip the ones that aren't - while (!this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_star`] && (startInd + 1) % this.childLayoutPairs.length != this.layoutDoc._carousel_index) { + while (!this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_star`] && (startInd + 1) % this.childLayoutPairs.length !== this.layoutDoc._carousel_index) { startInd = (startInd + 1) % this.childLayoutPairs.length; } this.layoutDoc._carousel_index = startInd; // if there aren't any starred, show all cards if (!this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_star`]) { - this.layoutDoc[`filterOp`] = 'all'; + this.layoutDoc.filterOp = 'all'; } } // if the practice filter is selected - if (this.layoutDoc[`filterOp`] == 'practice') { + if (this.layoutDoc.filterOp === 'practice') { // go to a new index that is missed, skip the ones that are correct - while (this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] == 'correct' && (startInd + 1) % this.childLayoutPairs.length != this.layoutDoc._carousel_index) { + while (this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] === 'correct' && (startInd + 1) % this.childLayoutPairs.length !== this.layoutDoc._carousel_index) { startInd = (startInd + 1) % this.childLayoutPairs.length; } this.layoutDoc._carousel_index = startInd; // if the user has gone through all of the cards and gotten them all correct, show all cards and exit practice mode - if (this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] == 'correct') { - this.layoutDoc[`filterOp`] = 'all'; + if (this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] === 'correct') { + this.layoutDoc.filterOp = 'all'; // set all the cards to missed - for (var i = 0; i < this.childLayoutPairs.length; i++) { + for (let i = 0; i < this.childLayoutPairs.length; i++) { const curDoc = this.childLayoutPairs?.[NumCast(i)]; curDoc.layout[`${this.fieldKey}_missed`] = undefined; } @@ -93,35 +93,35 @@ export class CollectionCarouselView extends CollectionSubView() { e.stopPropagation(); this.layoutDoc._carousel_index = (NumCast(this.layoutDoc._carousel_index) - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length; - var startInd = this.layoutDoc._carousel_index; + let startInd = this.layoutDoc._carousel_index; // if the star filter is selected - if (this.layoutDoc[`filterOp`] == 'star') { + if (this.layoutDoc.filterOp === 'star') { // go to a new index that is starred, skip the ones that aren't - while (!this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_star`] && (startInd - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length != this.layoutDoc._carousel_index) { + while (!this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_star`] && (startInd - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length !== this.layoutDoc._carousel_index) { startInd = (startInd - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length; } this.layoutDoc._carousel_index = startInd; // if there aren't any starred, show all cards if (!this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_star`]) { - this.layoutDoc[`filterOp`] = 'all'; + this.layoutDoc.filterOp = 'all'; } } // if the practice filter is selected - if (this.layoutDoc[`filterOp`] == 'practice') { + if (this.layoutDoc.filterOp === 'practice') { // go to a new index that is missed, skip the ones that are correct - while (this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] == 'correct' && (startInd - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length != this.layoutDoc._carousel_index) { + while (this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] === 'correct' && (startInd - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length !== this.layoutDoc._carousel_index) { startInd = (startInd - 1 + this.childLayoutPairs.length) % this.childLayoutPairs.length; } this.layoutDoc._carousel_index = startInd; // See all flashcards when finish going through practice mode and set all of the flashcards back to - if (this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] == 'correct') { - this.layoutDoc[`filterOp`] = 'all'; + if (this.childLayoutPairs?.[NumCast(startInd)].layout[`${this.fieldKey}_missed`] === 'correct') { + this.layoutDoc.filterOp = 'all'; - for (var i = 0; i < this.childLayoutPairs.length; i++) { + for (let i = 0; i < this.childLayoutPairs.length; i++) { const curDoc = this.childLayoutPairs?.[NumCast(i)]; curDoc.layout[`${this.fieldKey}_missed`] = undefined; } @@ -136,7 +136,7 @@ export class CollectionCarouselView extends CollectionSubView() { e.stopPropagation(); const curDoc = this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)]; if (!curDoc) return; - if (curDoc.layout[`${this.fieldKey}_star`] == undefined) curDoc.layout[`${this.fieldKey}_star`] = true; + if (curDoc.layout[`${this.fieldKey}_star`] === undefined) curDoc.layout[`${this.fieldKey}_star`] = true; else curDoc.layout[`${this.fieldKey}_star`] = !curDoc.layout[`${this.fieldKey}_star`]; }; @@ -207,7 +207,7 @@ export class CollectionCarouselView extends CollectionSubView() { ); } @computed get buttons() { - if (!this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)]) return; + if (!this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)]) return null; return ( <>
@@ -217,13 +217,13 @@ export class CollectionCarouselView extends CollectionSubView() {
- +
-
this.missed(e, 'missed')} style={{ visibility: this.layoutDoc[`filterOp`] == 'practice' ? 'visible' : 'hidden' }}> - +
this.missed(e, 'missed')} style={{ visibility: this.layoutDoc.filterOp === 'practice' ? 'visible' : 'hidden' }}> +
-
this.missed(e, 'correct')} style={{ visibility: this.layoutDoc[`filterOp`] == 'practice' ? 'visible' : 'hidden' }}> - +
this.missed(e, 'correct')} style={{ visibility: this.layoutDoc.filterOp === 'practice' ? 'visible' : 'hidden' }}> +
); @@ -242,7 +242,7 @@ export class CollectionCarouselView extends CollectionSubView() { {/* Displays a message to the user to add more flashcards if they are in practice mode and no flashcards are there. */}

Recently missed!

diff --git a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx index 0bcaa06de..034a38e9c 100644 --- a/src/client/views/nodes/CollectionFreeFormDocumentView.tsx +++ b/src/client/views/nodes/CollectionFreeFormDocumentView.tsx @@ -240,16 +240,14 @@ export class CollectionFreeFormDocumentView extends DocComponent DocumentView.SelectView(DocumentView.getDocumentView(topDoc, containerDocView), false), 0); } -- cgit v1.2.3-70-g09d2