Hansimov commited on
Commit
f9cfb3b
·
1 Parent(s): e287906

:recycle: [Refactor] SendUserInputButtonBinder: Remove post_user_input() to avoid confusion

Browse files
Files changed (1) hide show
  1. components/buttons_binder.js +5 -12
components/buttons_binder.js CHANGED
@@ -58,7 +58,7 @@ class SendUserInputButtonBinder {
58
  button.attr("status") === "send"
59
  ) {
60
  event.preventDefault();
61
- await this.send(button);
62
  }
63
  });
64
  }
@@ -69,25 +69,19 @@ class SendUserInputButtonBinder {
69
  }
70
  let status = button.attr("status");
71
  if (status === "send") {
72
- this.send(button);
 
73
  } else if (status === "stop") {
74
- this.stop(button);
75
- return;
76
  } else {
77
  console.log("No action");
78
  }
79
  }
80
 
81
  async send(button) {
82
- // console.log("Send");
83
  let button_icon = button.find("i");
84
  button.attr("status", "stop").attr("title", "Stop");
85
  button_icon.removeClass().addClass("fa fa-circle-pause fa-fade-fast");
86
- await this.post_user_input();
87
- await this.stop(button);
88
- }
89
-
90
- async post_user_input() {
91
  let user_input_content = $("#user-input").val();
92
  console.log(user_input_content);
93
  // empty user input and reset height
@@ -100,12 +94,11 @@ class SendUserInputButtonBinder {
100
  this.requester.create_messager_components();
101
  start_latest_message_animation();
102
  await this.requester.post();
103
- this.requester.stop();
104
  }
105
  }
106
 
107
  async stop(button) {
108
- // console.log("Stop");
109
  let button_icon = button.find("i");
110
  stop_latest_message_animation();
111
  button.attr("status", "send").attr("title", "Send");
 
58
  button.attr("status") === "send"
59
  ) {
60
  event.preventDefault();
61
+ await this.handle_user_input(button);
62
  }
63
  });
64
  }
 
69
  }
70
  let status = button.attr("status");
71
  if (status === "send") {
72
+ await this.send(button);
73
+ await this.stop(button);
74
  } else if (status === "stop") {
75
+ await this.stop(button);
 
76
  } else {
77
  console.log("No action");
78
  }
79
  }
80
 
81
  async 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");
 
 
 
 
 
85
  let user_input_content = $("#user-input").val();
86
  console.log(user_input_content);
87
  // empty user input and reset height
 
94
  this.requester.create_messager_components();
95
  start_latest_message_animation();
96
  await this.requester.post();
 
97
  }
98
  }
99
 
100
  async stop(button) {
101
+ await this.requester.stop();
102
  let button_icon = button.find("i");
103
  stop_latest_message_animation();
104
  button.attr("status", "send").attr("title", "Send");