Move SearchState from app.py to search_state.py (no behavior change)

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.
This commit is contained in:
pax 2026-04-08 14:32:46 -05:00
parent 4c166ac725
commit 591c7c3118
2 changed files with 21 additions and 12 deletions

View File

@ -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

View File

@ -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)