aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/pdf/AnchorMenu.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/views/pdf/AnchorMenu.tsx')
-rw-r--r--src/client/views/pdf/AnchorMenu.tsx22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/client/views/pdf/AnchorMenu.tsx b/src/client/views/pdf/AnchorMenu.tsx
index 63c8f9145..6bcfbe4c2 100644
--- a/src/client/views/pdf/AnchorMenu.tsx
+++ b/src/client/views/pdf/AnchorMenu.tsx
@@ -47,6 +47,7 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
// GPT additions (flow 2)
@observable private summarizedText: string = '';
+ @observable private loadingSummary: boolean = false;
@observable private showGPTPopup: boolean = false;
@action
setGPTPopupVis = (vis: boolean) => {
@@ -56,6 +57,10 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
setSummarizedText = (txt: string) => {
this.summarizedText = txt;
};
+ @action
+ setLoading = (loading: boolean) => {
+ this.loadingSummary = loading;
+ };
private selectedText: string = '';
setSelectedText = (txt: string) => {
@@ -98,7 +103,13 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
componentDidMount() {
this._disposer2 = reaction(
() => this._opacity,
- opacity => !opacity && (this._showLinkPopup = false),
+ opacity => {
+ if (!opacity) {
+ this._showLinkPopup = false;
+ this.setGPTPopupVis(false);
+ this.setSummarizedText('');
+ }
+ },
{ fireImmediately: true }
);
this._disposer = reaction(
@@ -106,6 +117,7 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
selected => {
this._showLinkPopup = false;
this.setGPTPopupVis(false);
+ this.setSummarizedText('');
AnchorMenu.Instance.fadeOut(true);
}
);
@@ -117,12 +129,14 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
invokeGPT = async (e: React.PointerEvent) => {
this.setGPTPopupVis(true);
+ this.setLoading(true);
const res = await gptSummarize(this.selectedText);
if (res) {
this.setSummarizedText(res);
} else {
this.setSummarizedText('Something went wrong.');
}
+ this.setLoading(false);
};
pointerDown = (e: React.PointerEvent) => {
@@ -229,12 +243,12 @@ export class AnchorMenu extends AntimodeMenu<AntimodeMenuProps> {
<FontAwesomeIcon icon="comment-alt" size="lg" />
</button>
</Tooltip>
- <Tooltip key="gpt" title={<div className="dash-tooltip">Summarize with GPT-3</div>}>
- <button className="antimodeMenu-button annotate" onPointerDown={this.getGPTSummary} style={{ cursor: 'grab' }}>
+ <Tooltip key="gpt" title={<div className="dash-tooltip">Summarize with AI</div>}>
+ <button className="antimodeMenu-button annotate" onPointerDown={this.invokeGPT} style={{ cursor: 'grab' }}>
<FontAwesomeIcon icon="comment-dots" size="lg" />
</button>
</Tooltip>
- <GPTPopup key="gptpopup" visible={this.showGPTPopup} text={this.summarizedText} />
+ <GPTPopup key="gptpopup" visible={this.showGPTPopup} text={this.summarizedText} loadingSummary={this.loadingSummary} />
{AnchorMenu.Instance.OnAudio === unimplementedFunction ? null : (
<Tooltip key="annoaudiotate" title={<div className="dash-tooltip">Click to Record Annotation</div>}>
<button className="antimodeMenu-button annotate" onPointerDown={this.audioDown} style={{ cursor: 'grab' }}>