[presto] Use placeholder cover when scrolling record detail view
This commit is contained in:
+5
-5
@@ -1997,6 +1997,11 @@ def _draw_detail_cover(app, rec, y):
|
||||
if y >= HEIGHT:
|
||||
return
|
||||
|
||||
if app.touch.dragging:
|
||||
_draw_placeholder(DETAIL_COVER_X, y,
|
||||
DETAIL_COVER_SIZE, DETAIL_COVER_SIZE)
|
||||
return
|
||||
|
||||
cover_url = _record_detail_cover_url(rec)
|
||||
|
||||
if not cover_url:
|
||||
@@ -2004,12 +2009,7 @@ def _draw_detail_cover(app, rec, y):
|
||||
DETAIL_COVER_SIZE, DETAIL_COVER_SIZE)
|
||||
return
|
||||
|
||||
# Use cached data or fetch
|
||||
data = rec.get("_detail_thumb_data", None)
|
||||
if data is None and app.touch.dragging:
|
||||
_draw_placeholder(DETAIL_COVER_X, y,
|
||||
DETAIL_COVER_SIZE, DETAIL_COVER_SIZE)
|
||||
return
|
||||
|
||||
if data is None and not rec.get("_detail_thumb_failed", False):
|
||||
data = fetch_thumbnail(app, cover_url)
|
||||
|
||||
@@ -96,6 +96,37 @@ class TestSmokeScreens:
|
||||
main_module.draw_record_detail(app)
|
||||
self._screenshot(main_module, "record-detail")
|
||||
|
||||
def test_record_detail_uses_placeholder_cover_while_dragging(
|
||||
self, main_module, monkeypatch
|
||||
):
|
||||
"""Detail scroll redraws avoid decoding a cached medium JPEG."""
|
||||
app = self._make_app(main_module)
|
||||
app.screen = main_module.STATE_RECORD
|
||||
app.day.selected_day = 15
|
||||
app.touch.dragging = True
|
||||
|
||||
rec = make_mock_record(0)
|
||||
rec["_detail_thumb_data"] = b"cached-jpeg"
|
||||
rec["_detail_thumb_failed"] = False
|
||||
app.day.records = [rec]
|
||||
app.detail.selected_index = 0
|
||||
app.detail.source_screen = main_module.STATE_DAY
|
||||
|
||||
calls = {"jpeg": 0, "placeholder": 0}
|
||||
|
||||
def _count_jpeg(*_args):
|
||||
calls["jpeg"] += 1
|
||||
|
||||
def _count_placeholder(*_args):
|
||||
calls["placeholder"] += 1
|
||||
|
||||
monkeypatch.setattr(main_module, "draw_jpeg", _count_jpeg)
|
||||
monkeypatch.setattr(main_module, "_draw_placeholder", _count_placeholder)
|
||||
|
||||
main_module.draw_record_detail(app)
|
||||
|
||||
assert calls == {"jpeg": 0, "placeholder": 1}
|
||||
|
||||
def test_cover_contract_uses_api_sized_images(self, main_module):
|
||||
"""Cover helpers use the named API sizes expected by the display."""
|
||||
rec = make_mock_record(0)
|
||||
|
||||
Reference in New Issue
Block a user