:boom: [Fix] Stop button not working for await mechanism
Browse files- components/buttons_binder.js +15 -15
components/buttons_binder.js
CHANGED
@@ -47,38 +47,38 @@ class SendUserInputButtonBinder {
|
|
47 |
bind() {
|
48 |
const button = $("#send-user-input");
|
49 |
button.attr("status", "send").attr("title", "Send");
|
50 |
-
button.click(
|
51 |
-
|
52 |
});
|
53 |
|
54 |
-
$("#user-input").keypress(
|
55 |
if (
|
56 |
event.key === "Enter" &&
|
57 |
!event.shiftKey &&
|
58 |
button.attr("status") === "send"
|
59 |
) {
|
60 |
event.preventDefault();
|
61 |
-
|
62 |
}
|
63 |
});
|
64 |
}
|
65 |
-
|
66 |
let user_input_content = $("#user-input").val();
|
67 |
-
if (user_input_content === "") {
|
68 |
-
return;
|
69 |
-
}
|
70 |
let status = button.attr("status");
|
71 |
if (status === "send") {
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
74 |
} else if (status === "stop") {
|
75 |
-
|
76 |
} else {
|
77 |
console.log("No action");
|
78 |
}
|
79 |
}
|
80 |
|
81 |
-
|
82 |
let button_icon = button.find("i");
|
83 |
button.attr("status", "stop").attr("title", "Stop");
|
84 |
button_icon.removeClass().addClass("fa fa-circle-pause fa-fade-fast");
|
@@ -93,12 +93,12 @@ class SendUserInputButtonBinder {
|
|
93 |
this.requester = new ChatCompletionsRequester(user_input_content);
|
94 |
this.requester.create_messager_components();
|
95 |
start_latest_message_animation();
|
96 |
-
|
97 |
}
|
98 |
}
|
99 |
|
100 |
-
|
101 |
-
|
102 |
let button_icon = button.find("i");
|
103 |
stop_latest_message_animation();
|
104 |
button.attr("status", "send").attr("title", "Send");
|
|
|
47 |
bind() {
|
48 |
const button = $("#send-user-input");
|
49 |
button.attr("status", "send").attr("title", "Send");
|
50 |
+
button.click(() => {
|
51 |
+
this.handle_user_input(button);
|
52 |
});
|
53 |
|
54 |
+
$("#user-input").keypress((event) => {
|
55 |
if (
|
56 |
event.key === "Enter" &&
|
57 |
!event.shiftKey &&
|
58 |
button.attr("status") === "send"
|
59 |
) {
|
60 |
event.preventDefault();
|
61 |
+
this.handle_user_input(button);
|
62 |
}
|
63 |
});
|
64 |
}
|
65 |
+
handle_user_input(button) {
|
66 |
let user_input_content = $("#user-input").val();
|
|
|
|
|
|
|
67 |
let status = button.attr("status");
|
68 |
if (status === "send") {
|
69 |
+
if (user_input_content === "") {
|
70 |
+
return;
|
71 |
+
} else {
|
72 |
+
this.send(button);
|
73 |
+
}
|
74 |
} else if (status === "stop") {
|
75 |
+
this.stop(button);
|
76 |
} else {
|
77 |
console.log("No action");
|
78 |
}
|
79 |
}
|
80 |
|
81 |
+
send(button) {
|
82 |
let button_icon = button.find("i");
|
83 |
button.attr("status", "stop").attr("title", "Stop");
|
84 |
button_icon.removeClass().addClass("fa fa-circle-pause fa-fade-fast");
|
|
|
93 |
this.requester = new ChatCompletionsRequester(user_input_content);
|
94 |
this.requester.create_messager_components();
|
95 |
start_latest_message_animation();
|
96 |
+
this.requester.post();
|
97 |
}
|
98 |
}
|
99 |
|
100 |
+
stop(button) {
|
101 |
+
this.requester.stop();
|
102 |
let button_icon = button.find("i");
|
103 |
stop_latest_message_animation();
|
104 |
button.attr("status", "send").attr("title", "Send");
|