Skip to content

Commit

Permalink
fix: Fix notification settings can't be saved
Browse files Browse the repository at this point in the history
  • Loading branch information
seriaati committed Feb 29, 2024
1 parent 30c958d commit e7554e0
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions hoyo_buddy/ui/hoyo/checkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from ...bot import emojis
from ...bot.error_handler import get_error_embed
from ...bot.translator import LocaleStr, Translator
from ...db.models import AccountNotifSettings
from ...draw.hoyo import checkin
from ...draw.static import download_and_save_static_images
from ...embeds import DefaultEmbed
Expand Down Expand Up @@ -204,7 +205,11 @@ def __init__(self) -> None:

async def callback(self, i: "INTERACTION") -> Any:
await self.view.account.fetch_related("notif_settings")
go_back_button = GoBackButton(self.view.children, self.view.get_embeds(i.message))
go_back_button = GoBackButton(
self.view.children,
self.view.get_embeds(i.message),
self.view.get_attachments(i.message),
)
self.view.clear_items()
self.view.add_item(go_back_button)
self.view.add_item(
Expand All @@ -225,8 +230,9 @@ def __init__(self, current_toggle: bool) -> None:

async def callback(self, i: "INTERACTION") -> Any:
await super().callback(i)
self.view.account.notif_settings.notify_on_checkin_failure = self.current_toggle
await self.view.account.notif_settings.save()
await AccountNotifSettings.filter(account=self.view.account).update(
notify_on_checkin_failure=self.current_toggle
)


class NotifyOnSuccessToggle(ToggleButton[CheckInUI]):
Expand All @@ -238,5 +244,6 @@ def __init__(self, current_toggle: bool) -> None:

async def callback(self, i: "INTERACTION") -> Any:
await super().callback(i)
self.view.account.notif_settings.notify_on_checkin_success = self.current_toggle
await self.view.account.notif_settings.save()
await AccountNotifSettings.filter(account=self.view.account).update(
notify_on_checkin_success=self.current_toggle
)

0 comments on commit e7554e0

Please sign in to comment.