From b453414dc2bb11d56c5dcb2a73d389eefabff7d5 Mon Sep 17 00:00:00 2001
From: bobzel <zzzman@gmail.com>
Date: Mon, 2 Sep 2024 12:16:43 -0400
Subject: cleaned up updateIcon to use promises to avoid a bunch of setTimeouts

---
 src/client/views/InkTranscription.tsx | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

(limited to 'src/client/views/InkTranscription.tsx')

diff --git a/src/client/views/InkTranscription.tsx b/src/client/views/InkTranscription.tsx
index 485a0e7c4..26e0aa372 100644
--- a/src/client/views/InkTranscription.tsx
+++ b/src/client/views/InkTranscription.tsx
@@ -3,7 +3,7 @@ import { action, observable } from 'mobx';
 import * as React from 'react';
 import { Doc, DocListCast } from '../../fields/Doc';
 import { InkData, InkField, InkTool } from '../../fields/InkField';
-import { Cast, DateCast, ImageCast, NumCast, StrCast } from '../../fields/Types';
+import { Cast, DateCast, DocCast, ImageCast, NumCast, StrCast } from '../../fields/Types';
 import { aggregateBounds } from '../../Utils';
 import { DocumentType } from '../documents/DocumentTypes';
 import { CollectionFreeFormView, MarqueeView } from './collections/collectionFreeForm';
@@ -273,7 +273,7 @@ export class InkTranscription extends React.Component {
                     DocumentView.getDocumentView(this.currGroup)?.ComponentView?.updateIcon?.();
                     this.currGroup.transcription = text;
                     this.currGroup.title = text;
-                    let image = await this.getIcon();
+                    let image = await DocumentView.GetDocImage(this.currGroup);
                     const pathname = image?.url.href as string;
                     console.log(image?.url);
                     console.log(image);
@@ -300,16 +300,6 @@ export class InkTranscription extends React.Component {
             }
         }
     };
-    async getIcon() {
-        const docView = DocumentView.getDocumentView(this.currGroup);
-        console.log(this.currGroup);
-        if (docView) {
-            console.log(docView);
-            docView.ComponentView?.updateIcon?.();
-            return new Promise<ImageField | undefined>(res => setTimeout(() => res(ImageCast(docView.Document.icon)), 1000));
-        }
-        return undefined;
-    }
     imageUrlToBase64 = async (imageUrl: string): Promise<string> => {
         try {
             const response = await fetch(imageUrl);
-- 
cgit v1.2.3-70-g09d2

