From 591c7c3118a706564adeb9d18a12e566f1ad79ba Mon Sep 17 00:00:00 2001 From: pax Date: Wed, 8 Apr 2026 14:32:46 -0500 Subject: [PATCH] Move SearchState from app.py to search_state.py (no behavior change) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Step 8 of the gui/app.py + gui/preview.py structural refactor — first move out of app.py. Pure copy: the SearchState dataclass moves to its own module. app.py grows its first re-export shim block at the bottom so any internal `SearchState(...)` reference in BooruApp keeps working through the module-namespace lookup. Shim removed in commit 14. --- booru_viewer/gui/app.py | 16 ++++------------ booru_viewer/gui/search_state.py | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 booru_viewer/gui/search_state.py diff --git a/booru_viewer/gui/app.py b/booru_viewer/gui/app.py index 145069a..28e3ca4 100644 --- a/booru_viewer/gui/app.py +++ b/booru_viewer/gui/app.py @@ -51,18 +51,6 @@ from .settings import SettingsDialog log = logging.getLogger("booru") -@dataclass -class SearchState: - """Mutable state that resets on every new search.""" - shown_post_ids: set[int] = field(default_factory=set) - page_cache: dict[int, list] = field(default_factory=dict) - infinite_exhausted: bool = False - infinite_last_page: int = 0 - infinite_api_exhausted: bool = False - nav_page_turn: str | None = None - append_queue: list = field(default_factory=list) - - class LogHandler(logging.Handler, QObject): """Logging handler that emits to a QTextEdit.""" @@ -3606,3 +3594,7 @@ def run() -> None: window = BooruApp() window.show() sys.exit(app.exec()) + + +# -- Refactor compatibility shims (deleted in commit 14) -- +from .search_state import SearchState # re-export for refactor compat diff --git a/booru_viewer/gui/search_state.py b/booru_viewer/gui/search_state.py new file mode 100644 index 0000000..9ff598a --- /dev/null +++ b/booru_viewer/gui/search_state.py @@ -0,0 +1,17 @@ +"""Mutable per-search state container.""" + +from __future__ import annotations + +from dataclasses import dataclass, field + + +@dataclass +class SearchState: + """Mutable state that resets on every new search.""" + shown_post_ids: set[int] = field(default_factory=set) + page_cache: dict[int, list] = field(default_factory=dict) + infinite_exhausted: bool = False + infinite_last_page: int = 0 + infinite_api_exhausted: bool = False + nav_page_turn: str | None = None + append_queue: list = field(default_factory=list)