From 525f29aa7a3dc9f7e85937964ff90f89ed154702 Mon Sep 17 00:00:00 2001 From: James Turk Date: Fri, 10 Jan 2025 23:22:37 -0600 Subject: [PATCH] fix bug with buggling and saving --- src/tt/controller/tasks.py | 6 ++---- src/tt/tui/tasks.py | 10 +++++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/tt/controller/tasks.py b/src/tt/controller/tasks.py index 711a84c..d2b4fb6 100644 --- a/src/tt/controller/tasks.py +++ b/src/tt/controller/tasks.py @@ -108,15 +108,13 @@ def save_view(name: str, *, filters: dict, sort_string: str) -> SavedSearch: filters_json = json.dumps(filters) with db.atomic(): - if SavedSearch.select(SavedSearch.name == name).exists(): + if SavedSearch.select().where(SavedSearch.name == name).exists(): query = SavedSearch.update( filters=filters_json, sort_string=sort_string ).where(SavedSearch.name == name) query.execute() else: - return SavedSearch.create( - name=name, filters=filters_json, sort_string=sort_string - ) + SavedSearch.create(name=name, filters=filters_json, sort_string=sort_string) def get_saved_view_names() -> list[str]: diff --git a/src/tt/tui/tasks.py b/src/tt/tui/tasks.py index cc7c4d6..5e4ac41 100644 --- a/src/tt/tui/tasks.py +++ b/src/tt/tui/tasks.py @@ -87,14 +87,14 @@ class TT(TableEditor): # Override to add save/load view if self.mode == "save-view": save_view(event.value, filters=self.filters, sort_string=self.sort_string) + self._hide_input() + event.prevent_default() elif self.mode == "load-view": self._load_view(event.value) self.refresh_tasks(restore_cursor=False) - else: - # https://textual.textualize.io/guide/events/#bubbling - # not needed - # super().on_input_submitted(event) - return + self._hide_input() + event.prevent_default() + # if event isn't handled here it will bubble to parent def refresh_items(self): items = get_tasks(