Fix add, remove of the text to speech loader element in Obsidian

This commit is contained in:
Debanjum Singh Solanky
2024-07-04 17:38:45 +05:30
parent 814aca6d69
commit 516af86575

View File

@@ -318,7 +318,6 @@ export class KhojChatView extends KhojPaneView {
speechIcon = event.target as Element; speechIcon = event.target as Element;
} }
speechButton.innerHTML = "";
speechButton.appendChild(loader); speechButton.appendChild(loader);
speechButton.disabled = true; speechButton.disabled = true;
@@ -339,15 +338,13 @@ export class KhojChatView extends KhojPaneView {
source.connect(context.destination); source.connect(context.destination);
source.start(0); source.start(0);
source.onended = function() { source.onended = function() {
speechButton.innerHTML = ""; speechButton.removeChild(loader);
speechButton.appendChild(speechIcon);
speechButton.disabled = false; speechButton.disabled = false;
}; };
}) })
.catch(err => { .catch(err => {
console.error("Error playing speech:", err); console.error("Error playing speech:", err);
speechButton.innerHTML = ""; speechButton.removeChild(loader);
speechButton.appendChild(speechIcon);
speechButton.disabled = false; // Consider enabling the button again to allow retrying speechButton.disabled = false; // Consider enabling the button again to allow retrying
}); });
} }