diff --git a/hoyo_buddy/ui/hoyo/profile/view.py b/hoyo_buddy/ui/hoyo/profile/view.py index 68a4c624..223630ff 100644 --- a/hoyo_buddy/ui/hoyo/profile/view.py +++ b/hoyo_buddy/ui/hoyo/profile/view.py @@ -40,6 +40,7 @@ from hoyo_buddy.ui import Button, Select, View from hoyo_buddy.ui.hoyo.profile.items.image_settings_btn import ImageSettingsButton from hoyo_buddy.ui.hoyo.profile.items.team_card_settings_btn import TeamCardSettingsButton +from hoyo_buddy.ui.hoyo.profile.templates import TEMPLATES from hoyo_buddy.utils import blur_uid, format_float, human_format_number from .card_settings import get_card_settings @@ -137,6 +138,11 @@ async def fetch_cache_extras(self) -> dict[str, Any]: self.cache_extras = cache.extras return cache.extras + async def _fix_invalid_template(self, card_settings: CardSettings) -> None: + if self.game not in TEMPLATES or card_settings.template not in TEMPLATES[self.game]: + card_settings.template = "hb1" + await card_settings.save(update_fields=("template",)) + async def _get_character_rank( self, character: Character, *, with_detail: bool = False ) -> str | None: @@ -533,6 +539,8 @@ async def draw_card( card_settings.template = "hb1" await card_settings.save(update_fields=("template",)) + await self._fix_invalid_template(card_settings) + template = card_settings.template draw_input = DrawInput( dark_mode=card_settings.dark_mode,