From 6fa61343a3e63a61747bc7123810190057d0bfe4 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Wed, 29 Jan 2025 12:14:12 -0500
Subject: cleaned up filter icons.

---
 src/client/views/pdf/GPTPopup/GPTPopup.tsx | 34 ++++++++++--------------------
 1 file changed, 11 insertions(+), 23 deletions(-)

(limited to 'src/client/views/pdf/GPTPopup/GPTPopup.tsx')

diff --git a/src/client/views/pdf/GPTPopup/GPTPopup.tsx b/src/client/views/pdf/GPTPopup/GPTPopup.tsx
index 4028ef479..c33b81eb4 100644
--- a/src/client/views/pdf/GPTPopup/GPTPopup.tsx
+++ b/src/client/views/pdf/GPTPopup/GPTPopup.tsx
@@ -188,8 +188,8 @@ export class GPTPopup extends ObservableReactComponent<object> {
 
         const selected = DocumentView.SelectedDocs().lastElement();
 
-        const questionText = 'Question: ' + StrCast(selected['gptInputText']);
-        const rubricText = 'Rubric: ' + StrCast(selected['gptRubric']);
+        const questionText = 'Question: ' + StrCast(selected.gptInputText);
+        const rubricText = 'Rubric: ' + StrCast(selected.gptRubric);
         const queryText = questionText + ' UserAnswer: ' + this.quizAnswer + '. ' + 'Rubric' + rubricText;
 
         try {
@@ -262,27 +262,15 @@ export class GPTPopup extends ObservableReactComponent<object> {
 
         try {
             const questionType = await gptAPICall(this.chatSortPrompt, GPTCallType.TYPE);
-            const questionNumber = questionType.split(' ')[0];
-            let res = '';
-
-            switch (questionNumber) {
-                case '1':
-                case '2':
-                case '4':
-                    res = await gptAPICall(this.sortDesc, GPTCallType.SUBSET, this.chatSortPrompt);
-                    break;
-                case '6':
-                    res = await gptAPICall(this.sortDesc, GPTCallType.SORT, this.chatSortPrompt);
-                    break;
-                default:
-                    {
-                        const selected = DocumentView.SelectedDocs().lastElement();
-                        const questionText = StrCast(selected?.gptInputText);
-
-                        res = await gptAPICall(questionText, GPTCallType.INFO, this.chatSortPrompt);
-                    }
-                    break;
-            }
+            const questionNumber = questionType.split(' ')[0][0];
+            const res = await (() => {
+                switch (questionNumber) {
+                    case '1':
+                    case '2':
+                    case '4': return gptAPICall(this.sortDesc, GPTCallType.SUBSET, this.chatSortPrompt);
+                    case '6': return gptAPICall(this.sortDesc, GPTCallType.SORT, this.chatSortPrompt);
+                    default: return gptAPICall(StrCast(DocumentView.SelectedDocs().lastElement()?.gptInputText), GPTCallType.INFO, this.chatSortPrompt);
+                }})(); // prettier-ignore
 
             // Trigger the callback with the result
             if (this.onSortComplete) {
-- 
cgit v1.2.3-70-g09d2

