Skip to content

Commit

Permalink
[BUILD-868] Fix button state when closing chatbot using X (#1042)
Browse files Browse the repository at this point in the history
  • Loading branch information
abdnh authored Nov 29, 2024
1 parent 059c811 commit 1c786fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions ankihub/gui/web/ankihub_ai.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ class AnkiHubAI {
hideIframe() {
this.iframe.style.display = "none";
this.iframeVisible = false;
window.ankihubReviewerButtons.unselectAllButtons(false);
}

cardChanged(noteId) {
Expand Down
13 changes: 7 additions & 6 deletions ankihub/gui/web/reviewer_buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class AnkiHubReviewerButtons {
buttonContainer.style.flexDirection = "column";
}

setButtonState(buttonData, buttonElement, active) {
setButtonState(buttonData, buttonElement, active, sendToPython = true) {
buttonData.active = active;
if (active) {
buttonElement.style.backgroundColor = this.theme == "light" ? this.colorButtonSelectedLight : this.colorButtonSelectedDark;
Expand All @@ -101,16 +101,17 @@ class AnkiHubReviewerButtons {
buttonElement.style.backgroundColor = this.theme == "light" ? this.colorButtonLight : this.colorButtonDark;
}


const args = `{"buttonName": "${buttonData.name}", "isActive": "${buttonData.active}"}`
pycmd(`ankihub_reviewer_button_toggled ${args}`);
if(sendToPython) {
const args = `{"buttonName": "${buttonData.name}", "isActive": "${buttonData.active}"}`;
pycmd(`ankihub_reviewer_button_toggled ${args}`);
}
}

unselectAllButtons() {
unselectAllButtons(sendToPython = true) {
for (const buttonData of this.buttonsData) {
if (buttonData.active) {
const buttonElement = this.getButtonElement(buttonData.name);
this.setButtonState(buttonData, buttonElement, false);
this.setButtonState(buttonData, buttonElement, false, sendToPython);
}
}
}
Expand Down

0 comments on commit 1c786fe

Please sign in to comment.