improved async in closing chat windows. fixes #110
This commit is contained in:
parent
dd2e084bb4
commit
b0fdaf7037
2 changed files with 9 additions and 13 deletions
|
|
@ -231,19 +231,17 @@ class MessagesArea extends HTMLElement {
|
|||
//actionButton.textContent = browser.i18n.getMessage("chatgpt_win_get_answer");
|
||||
const fullTextHTMLAtAssignment = this.fullTextHTML.trim().replace(/^"|"$/g, '').replace(/^<p>"/, '<p>').replace(/"<\/p>$/, '</p>'); // strip quotation marks
|
||||
//console.log(">>>>>>>>>>>> fullTextHTMLAtAssignment: " + fullTextHTMLAtAssignment);
|
||||
actionButton.addEventListener('click', () => {
|
||||
actionButton.addEventListener('click', async () => {
|
||||
switch(promptData.action) {
|
||||
case "1": // do reply
|
||||
// console.log("[ThunderAI] (do reply) fullTextHTMLAtAssignment: " + fullTextHTMLAtAssignment);
|
||||
browser.runtime.sendMessage({command: "chatgpt_replyMessage", text: fullTextHTMLAtAssignment, tabId: promptData.tabId, mailMessageId: promptData.mailMessageId}).then(() => {
|
||||
browser.runtime.sendMessage({command: "chatgpt_close"});
|
||||
});
|
||||
await browser.runtime.sendMessage({command: "chatgpt_replyMessage", text: fullTextHTMLAtAssignment, tabId: promptData.tabId, mailMessageId: promptData.mailMessageId});
|
||||
browser.runtime.sendMessage({command: "chatgpt_close"});
|
||||
break;
|
||||
case "2": // replace text
|
||||
// console.log("[ThunderAI] (replace text) fullTextHTMLAtAssignment: " + fullTextHTMLAtAssignment);
|
||||
browser.runtime.sendMessage({command: "chatgpt_replaceSelectedText", text: fullTextHTMLAtAssignment, tabId: promptData.tabId, mailMessageId: promptData.mailMessageId}).then(() => {
|
||||
browser.runtime.sendMessage({command: "chatgpt_close"});
|
||||
});
|
||||
await browser.runtime.sendMessage({command: "chatgpt_replaceSelectedText", text: fullTextHTMLAtAssignment, tabId: promptData.tabId, mailMessageId: promptData.mailMessageId});
|
||||
browser.runtime.sendMessage({command: "chatgpt_close"});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -167,9 +167,8 @@ function addCustomDiv(prompt_action,tabId,mailMessageId) {
|
|||
btn_ok.textContent = browser.i18n.getMessage("chatgpt_win_get_answer");
|
||||
btn_ok.onclick = async function() {
|
||||
const response = getSelectedHtml();
|
||||
browser.runtime.sendMessage({command: "chatgpt_replyMessage", text: response, tabId: tabId, mailMessageId: mailMessageId}).then(() => {
|
||||
browser.runtime.sendMessage({command: "chatgpt_close"});
|
||||
});
|
||||
await browser.runtime.sendMessage({command: "chatgpt_replyMessage", text: response, tabId: tabId, mailMessageId: mailMessageId});
|
||||
browser.runtime.sendMessage({command: "chatgpt_close"});
|
||||
};
|
||||
break;
|
||||
case "2": // replace text
|
||||
|
|
@ -178,9 +177,8 @@ function addCustomDiv(prompt_action,tabId,mailMessageId) {
|
|||
btn_ok.onclick = async function() {
|
||||
const response = getSelectedHtml();
|
||||
//console.log('replace text: '+tabId)
|
||||
browser.runtime.sendMessage({command: "chatgpt_replaceSelectedText", text: response, tabId: tabId, mailMessageId: mailMessageId}).then(() => {
|
||||
browser.runtime.sendMessage({command: "chatgpt_close"});
|
||||
});
|
||||
await browser.runtime.sendMessage({command: "chatgpt_replaceSelectedText", text: response, tabId: tabId, mailMessageId: mailMessageId});
|
||||
browser.runtime.sendMessage({command: "chatgpt_close"});
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue