Rename prefetch modes, cap Aggressive to 3 rows radius
- Adjacent → Nearby (4 cardinals) - Full page → Aggressive (3 row radius ring, not entire grid) - Prevents fetching 500 images in infinite scroll mode
This commit is contained in:
parent
83bec9d649
commit
d385b8acee
@ -845,7 +845,7 @@ class BooruApp(QMainWindow):
|
|||||||
self._grid.setFocus()
|
self._grid.setFocus()
|
||||||
|
|
||||||
# Start prefetching from top of page
|
# Start prefetching from top of page
|
||||||
if self._db.get_setting("prefetch_mode") in ("Adjacent", "Full page") and posts:
|
if self._db.get_setting("prefetch_mode") in ("Nearby", "Aggressive") and posts:
|
||||||
self._prefetch_adjacent(0)
|
self._prefetch_adjacent(0)
|
||||||
|
|
||||||
# Infinite scroll: if first page doesn't fill viewport, load more
|
# Infinite scroll: if first page doesn't fill viewport, load more
|
||||||
@ -998,7 +998,7 @@ class BooruApp(QMainWindow):
|
|||||||
self._run_async(_load)
|
self._run_async(_load)
|
||||||
|
|
||||||
# Prefetch adjacent posts
|
# Prefetch adjacent posts
|
||||||
if self._db.get_setting("prefetch_mode") in ("Adjacent", "Full page"):
|
if self._db.get_setting("prefetch_mode") in ("Nearby", "Aggressive"):
|
||||||
self._prefetch_adjacent(index)
|
self._prefetch_adjacent(index)
|
||||||
|
|
||||||
def _prefetch_adjacent(self, index: int) -> None:
|
def _prefetch_adjacent(self, index: int) -> None:
|
||||||
@ -1009,7 +1009,7 @@ class BooruApp(QMainWindow):
|
|||||||
cols = self._grid._flow.columns
|
cols = self._grid._flow.columns
|
||||||
mode = self._db.get_setting("prefetch_mode")
|
mode = self._db.get_setting("prefetch_mode")
|
||||||
|
|
||||||
if mode == "Adjacent":
|
if mode == "Nearby":
|
||||||
# Just 4 cardinals: left, right, up, down
|
# Just 4 cardinals: left, right, up, down
|
||||||
order = []
|
order = []
|
||||||
for offset in [1, -1, cols, -cols]:
|
for offset in [1, -1, cols, -cols]:
|
||||||
@ -1017,10 +1017,12 @@ class BooruApp(QMainWindow):
|
|||||||
if 0 <= adj < total:
|
if 0 <= adj < total:
|
||||||
order.append(adj)
|
order.append(adj)
|
||||||
else:
|
else:
|
||||||
# Full page: ring expansion in all 8 directions
|
# Aggressive: ring expansion, capped to ~3 rows radius
|
||||||
|
max_radius = 3
|
||||||
|
max_posts = cols * max_radius * 2 + cols # ~3 rows above and below
|
||||||
seen = {index}
|
seen = {index}
|
||||||
order = []
|
order = []
|
||||||
for dist in range(1, total):
|
for dist in range(1, max_radius + 1):
|
||||||
ring = set()
|
ring = set()
|
||||||
for dy in (-dist, 0, dist):
|
for dy in (-dist, 0, dist):
|
||||||
for dx in (-dist, 0, dist):
|
for dx in (-dist, 0, dist):
|
||||||
@ -1035,7 +1037,7 @@ class BooruApp(QMainWindow):
|
|||||||
for adj in sorted(ring):
|
for adj in sorted(ring):
|
||||||
seen.add(adj)
|
seen.add(adj)
|
||||||
order.append(adj)
|
order.append(adj)
|
||||||
if len(order) >= total - 1:
|
if len(order) >= max_posts:
|
||||||
break
|
break
|
||||||
|
|
||||||
async def _prefetch_spiral():
|
async def _prefetch_spiral():
|
||||||
|
|||||||
@ -112,7 +112,7 @@ class SettingsDialog(QDialog):
|
|||||||
|
|
||||||
# Prefetch adjacent posts
|
# Prefetch adjacent posts
|
||||||
self._prefetch_combo = QComboBox()
|
self._prefetch_combo = QComboBox()
|
||||||
self._prefetch_combo.addItems(["Off", "Adjacent", "Full page"])
|
self._prefetch_combo.addItems(["Off", "Nearby", "Aggressive"])
|
||||||
prefetch_mode = self._db.get_setting("prefetch_mode") or "Off"
|
prefetch_mode = self._db.get_setting("prefetch_mode") or "Off"
|
||||||
idx = self._prefetch_combo.findText(prefetch_mode)
|
idx = self._prefetch_combo.findText(prefetch_mode)
|
||||||
if idx >= 0:
|
if idx >= 0:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user