diff options
author | bobzel <zzzman@gmail.com> | 2024-05-20 14:18:41 -0400 |
---|---|---|
committer | bobzel <zzzman@gmail.com> | 2024-05-20 14:18:41 -0400 |
commit | deb55ee338269d51d001f1120cd8d0d6a2c4bc6a (patch) | |
tree | 3afc1c127fb816d1ef28be213d8b1288436dd96e | |
parent | 4ad0dfca6a48b88a53e3add295d41cd0a223b722 (diff) |
lint fixes
-rw-r--r-- | package-lock.json | 3 | ||||
-rw-r--r-- | src/client/apis/gpt/GPT.ts | 2 | ||||
-rw-r--r-- | src/client/views/collections/CollectionCarouselView.tsx | 54 | ||||
-rw-r--r-- | src/client/views/nodes/CollectionFreeFormDocumentView.tsx | 6 |
4 files changed, 31 insertions, 34 deletions
diff --git a/package-lock.json b/package-lock.json index 9500b1488..3a4ca6668 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39228,8 +39228,7 @@ "node_modules/text-table": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", - "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", - "dev": true + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==" }, "node_modules/textarea-caret": { "version": "3.1.0", 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 ( <> <div key="back" className="carouselView-back" onClick={this.goback}> @@ -217,13 +217,13 @@ export class CollectionCarouselView extends CollectionSubView() { <FontAwesomeIcon icon="chevron-right" size="2x" /> </div> <div key="star" className="carouselView-star" onClick={this.star}> - <FontAwesomeIcon icon={'star'} color={this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)].layout[`${this.fieldKey}_star`] ? 'yellow' : 'gray'} size={'1x'} /> + <FontAwesomeIcon icon="star" color={this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)].layout[`${this.fieldKey}_star`] ? 'yellow' : 'gray'} size="1x" /> </div> - <div key="remove" className="carouselView-remove" onClick={e => this.missed(e, 'missed')} style={{ visibility: this.layoutDoc[`filterOp`] == 'practice' ? 'visible' : 'hidden' }}> - <FontAwesomeIcon icon={'xmark'} color={'red'} size={'1x'} /> + <div key="remove" className="carouselView-remove" onClick={e => this.missed(e, 'missed')} style={{ visibility: this.layoutDoc.filterOp === 'practice' ? 'visible' : 'hidden' }}> + <FontAwesomeIcon icon="xmark" color="red" size="1x" /> </div> - <div key="check" className="carouselView-check" onClick={e => this.missed(e, 'correct')} style={{ visibility: this.layoutDoc[`filterOp`] == 'practice' ? 'visible' : 'hidden' }}> - <FontAwesomeIcon icon={'check'} color={'green'} size={'1x'} /> + <div key="check" className="carouselView-check" onClick={e => this.missed(e, 'correct')} style={{ visibility: this.layoutDoc.filterOp === 'practice' ? 'visible' : 'hidden' }}> + <FontAwesomeIcon icon="check" color="green" size="1x" /> </div> </> ); @@ -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. */} <p style={{ - display: !this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)] && this.layoutDoc[`filterOp`] == 'practice' ? 'flex' : 'none', + display: !this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)] && this.layoutDoc.filterOp === 'practice' ? 'flex' : 'none', justifyContent: 'center', alignItems: 'center', height: '100%', @@ -258,7 +258,7 @@ export class CollectionCarouselView extends CollectionSubView() { position: 'relative', left: '10px', top: '10px', - display: this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)] ? (this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)].layout[`${this.fieldKey}_missed`] == 'missed' ? 'block' : 'none') : 'none', + display: this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)] ? (this.childLayoutPairs?.[NumCast(this.layoutDoc._carousel_index)].layout[`${this.fieldKey}_missed`] === 'missed' ? 'block' : 'none') : 'none', }}> Recently missed! </p> 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<CollectionFreeF if (screenXf) { DocumentView.DeselectAll(); if (topDoc.z) { - const spt = screenXf.inverse().transformPoint(NumCast(topDoc.x), NumCast(topDoc.y)); + [topDoc.x, topDoc.y] = screenXf.inverse().transformPoint(NumCast(topDoc.x), NumCast(topDoc.y)); topDoc.z = 0; - [topDoc.x, topDoc.y] = spt; this._props.removeDocument?.(topDoc); this._props.addDocTab(topDoc, OpenWhere.inParentFromScreen); } else { const spt = this.screenToLocalTransform().inverse().transformPoint(0, 0); - const fpt = screenXf.transformPoint(spt[0], spt[1]); + [topDoc.x, topDoc.y] = screenXf.transformPoint(spt[0], spt[1]); topDoc.z = 1; - [topDoc.x, topDoc.y] = fpt; } setTimeout(() => DocumentView.SelectView(DocumentView.getDocumentView(topDoc, containerDocView), false), 0); } |