Skip to content

Commit

Permalink
stop streamingh icon and one thread on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
bramses committed Mar 23, 2023
1 parent 3ae2645 commit 1f2a72c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Create a new chat file from a template specified in `Chat Template Folder`. Reme

[Infer the title of the chat from the messages](https://github.com/bramses/chatgpt-md/discussions/11). Requires at least 2 messages. Can be set in settings to run automatically after >4 messages.

#### Stop Streaming
#### Stop Streaming (Does not work on mobile)

Stops the stream. Useful if you want to stop the stream if you don't like where ChatGPT is heading/going too long.

Expand Down
2 changes: 1 addition & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ export default class ChatGPT_MD extends Plugin {
this.addCommand({
id: "stop-streaming",
name: "Stop streaming",
icon: "stop",
icon: "octagon",
editorCallback: (editor: Editor, view: MarkdownView) => {
streamManager.stopStreaming();
},
Expand Down
9 changes: 7 additions & 2 deletions stream.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Editor, Notice } from "obsidian";
import { Editor, Notice, Platform } from "obsidian";
import { SSE } from "sse";
import { unfinishedCodeBlock } from "helpers";

Expand All @@ -24,10 +24,14 @@ export class StreamManager {
constructor() {}

stopStreaming = () => {
if (Platform.isMobile) {
new Notice("[ChatGPT MD] Mobile not supported.")
return;
}
if (this.sse) {
this.manualClose = true;
this.sse.close();
console.log("[ChatGPT MD] SSE manually closed");
this.manualClose = true;
this.sse = null;
}
};
Expand Down Expand Up @@ -158,6 +162,7 @@ export class StreamManager {
if (this.manualClose) {
resolve(txt);
} else {
console.log("no manual close for abort");
reject(e);
}
});
Expand Down

0 comments on commit 1f2a72c

Please sign in to comment.