Skip to content

Commit

Permalink
Update sidebar on config close
Browse files Browse the repository at this point in the history
  • Loading branch information
RisingOrange committed Jan 16, 2025
1 parent e6b79d4 commit 1ffbcfe
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions ankihub/gui/reviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from ..gui.webview import AuthenticationRequestInterceptor, CustomWebPage # noqa: F401
from ..main.utils import Resource, mh_tag_to_resource
from ..settings import config, url_login
from .config_dialog import get_config_dialog_manager
from .js_message_handling import VIEW_NOTE_PYCMD, parse_js_message_kwargs
from .utils import get_ah_did_of_deck_or_ancestor_deck, using_qt5
from .web.templates import (
Expand Down Expand Up @@ -337,10 +338,28 @@ def setup():
reviewer_did_show_question.append(_remove_anking_button)
reviewer_did_show_answer.append(_remove_anking_button)

_setup_sidebar_update_on_config_close()

webview_did_receive_js_message.append(_on_js_message)
reviewer_will_end.append(_close_sidebar_and_clear_states_if_exists)


def _setup_sidebar_update_on_config_close() -> None:
"""Sets up the update of the reviewer buttons and resource tabs when the config dialog is closed."""
from .ankiaddonconfig import ConfigWindow

def setup_config_close_callback(window: ConfigWindow) -> None:
window.execute_on_close(notify_elements)

def notify_elements() -> None:
card = aqt.mw.reviewer.card
if card:
_notify_reviewer_buttons_of_card_change(card)
_notify_resource_tabs_of_card_change(card)

get_config_dialog_manager().on_window_open(setup_config_close_callback)


def _add_or_refresh_view_note_button(card: Card) -> None:
"""Adds the "View on AnkiHub" button to the reviewer toolbar if it doesn't exist yet,
or refreshes it if it does exist already."""
Expand Down

0 comments on commit 1ffbcfe

Please sign in to comment.