Skip to content

Commit

Permalink
Profile.is_any_profile_saved should be classmethod
Browse files Browse the repository at this point in the history
  • Loading branch information
mzebrak committed Dec 19, 2024
1 parent e98d5b9 commit 2115dcb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
6 changes: 3 additions & 3 deletions clive/__private/core/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ def is_newly_created(self) -> bool:
"""Determine if the profile is newly created (has not been saved yet)."""
return self._is_newly_created

@property
def is_any_profile_saved(self) -> bool:
return bool(self.list_profiles())
@classmethod
def is_any_profile_saved(cls) -> bool:
return bool(cls.list_profiles())

@classmethod
def is_only_one_profile_saved(cls) -> bool:
Expand Down
3 changes: 2 additions & 1 deletion clive/__private/ui/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from textual.reactive import var

from clive.__private.core.constants.terminal import TERMINAL_HEIGHT, TERMINAL_WIDTH
from clive.__private.core.profile import Profile
from clive.__private.core.world import TUIWorld
from clive.__private.logger import logger
from clive.__private.settings import safe_settings
Expand Down Expand Up @@ -170,7 +171,7 @@ def on_mount(self) -> None:
debug_loop_period_secs = safe_settings.dev.debug_loop_period_secs
self.set_interval(debug_loop_period_secs, self.__debug_log)

if self.world.profile.is_any_profile_saved:
if Profile.is_any_profile_saved():
self.switch_mode("unlock")
else:
self.switch_mode("create_profile")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from textual.widgets import Static

from clive.__private.core.constants.tui.messages import PRESS_HELP_MESSAGE
from clive.__private.core.profile import Profile
from clive.__private.ui.forms.create_profile.context import CreateProfileContext
from clive.__private.ui.forms.form_screen import FirstFormScreen
from clive.__private.ui.get_css import get_relative_css_path
Expand Down Expand Up @@ -39,7 +40,7 @@ def create_main_panel(self) -> ComposeResult:
yield CliveButton("Start!", id_="welcome-button-start")

def on_mount(self) -> None:
if self.profile.is_any_profile_saved:
if Profile.is_any_profile_saved():
# If the user requested profile creation from a `Unlock` screen, it is possible to back to the `Unlock`
# screen otherwise, during first time profile creation there is NO screen to go back to
self.bind(Binding("escape", "back", "Back"))
Expand Down

0 comments on commit 2115dcb

Please sign in to comment.