Skip to content

Commit

Permalink
add verification send message
Browse files Browse the repository at this point in the history
  • Loading branch information
GHimmel committed Jun 14, 2024
1 parent 018f40c commit 66742f5
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions chat-bubble.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
document.addEventListener("DOMContentLoaded", function () {
let isOpen = false;

let testSendMessage = false;

const fontLink = document.createElement("link");
fontLink.href =
"https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap";
Expand Down Expand Up @@ -285,6 +287,9 @@ document.addEventListener("DOMContentLoaded", function () {
`;
button.innerText = question;
button.onclick = async () => {
if (testSendMessage) {
return;
}
try {
addMessageUserChat(question);
await sendMessageFetch(question);
Expand Down Expand Up @@ -355,17 +360,6 @@ document.addEventListener("DOMContentLoaded", function () {

const gray = hexToRgb("#0C0D0D");

async function sendMessage() {
const message = chatInput.value.trim();
addMessageUserChat(message);

try {
await sendMessageFetch(message);
} catch (error) {
console.log(error);
}
}

const addMessageUserChat = (message) => {
if (message.trim() !== "") {
const userMessage = document.createElement("div");
Expand Down Expand Up @@ -474,7 +468,19 @@ document.addEventListener("DOMContentLoaded", function () {
}
};

let testSendMessage = false;
async function sendMessage() {
const message = chatInput.value.trim();
if (testSendMessage) {
return;
}
addMessageUserChat(message);

try {
await sendMessageFetch(message);
} catch (error) {
console.log(error);
}
}

const sendMessageFetch = async (message) => {
/// fetch para mandar mensaje
Expand Down

0 comments on commit 66742f5

Please sign in to comment.