From b7845adf2904e18e237638a0bf907c6ec0fe06ee Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Fri, 14 Feb 2025 00:23:41 -0500
Subject: more gptPopup cleanup and starting to allow it to work on any
 collection type.

---
 .../views/collections/CollectionCardDeckView.tsx       | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

(limited to 'src/client/views/collections/CollectionCardDeckView.tsx')

diff --git a/src/client/views/collections/CollectionCardDeckView.tsx b/src/client/views/collections/CollectionCardDeckView.tsx
index a3ec3884b..ba68504d7 100644
--- a/src/client/views/collections/CollectionCardDeckView.tsx
+++ b/src/client/views/collections/CollectionCardDeckView.tsx
@@ -75,13 +75,13 @@ export class CollectionCardView extends CollectionSubView() {
     }
 
     /**
-     * update's gpt's doc-text list and initializes callbacks
+     * update's gpt's doc-text list and initialize callbacks to respond to GPT output
      */
-    childPairStringListAndUpdateSortDesc = () =>
-        this.childPairStringList().then(sortDesc => {
-            GPTPopup.Instance.setSortDesc(sortDesc.join());
+    updateDocumentDescriptions = () =>
+        this.childPairStringList().then(docDescriptions => {
+            GPTPopup.Instance.setDocumentDescriptions(docDescriptions.join());
             GPTPopup.Instance.onGptResponse = this.processGptResponse;
-            GPTPopup.Instance.onQuizRandom = this.quizMode;
+            GPTPopup.Instance.onQuizRandom = this.randomlyChooseDoc;
         });
 
     componentDidMount() {
@@ -89,7 +89,7 @@ export class CollectionCardView extends CollectionSubView() {
             () => GPTPopup.Instance.Visible,
             vis => !vis && this.onGptHide()
         );
-        GPTPopup.Instance.setRegenerateCallback(this.Document, this.childPairStringListAndUpdateSortDesc);
+        GPTPopup.Instance.setRetrieveDocDescriptionsCallback(this.Document, this.updateDocumentDescriptions);
         this._props.setContentViewBox?.(this);
         // if card deck moves, then the child doc views are hidden so their screen to local transforms will return empty rectangles
         // when inquired from the dom (below in childScreenToLocal).  When the doc is actually rendered, we need to act like the
@@ -112,10 +112,8 @@ export class CollectionCardView extends CollectionSubView() {
 
     onGptHide = () => Doc.setDocFilter(this.Document, 'tags', '#chat', 'remove');
     componentWillUnmount() {
-        GPTPopup.Instance.setSortDesc('');
         GPTPopup.Instance.onGptResponse = undefined;
         GPTPopup.Instance.onQuizRandom = undefined;
-        GPTPopup.Instance.setRegenerateCallback(undefined, null);
         Object.keys(this._disposers).forEach(key => this._disposers[key]?.());
         this._dropDisposer?.();
     }
@@ -169,9 +167,7 @@ export class CollectionCardView extends CollectionSubView() {
     /**
      * When in quiz mode, randomly selects a document
      */
-    quizMode = () => {
-        this.layoutDoc._card_curDoc = this.childDocs[Math.floor(Math.random() * this.childDocs.length)];
-    };
+    randomlyChooseDoc = () => (this.layoutDoc._card_curDoc = this.childDocs[Math.floor(Math.random() * this.childDocs.length)]);
 
     setHoveredNodeIndex = action((index: number) => {
         if (!SnappingManager.IsDragging) this._hoveredNodeIndex = index;
-- 
cgit v1.2.3-70-g09d2

