diff --git a/make_post_sell/models/product.py b/make_post_sell/models/product.py index a882220..3fe1fc4 100644 --- a/make_post_sell/models/product.py +++ b/make_post_sell/models/product.py @@ -734,6 +734,10 @@ def get_ring_related_products(product, ring, forward=42, backward=3): idx = ring.index(product_id_str) ring_len = len(ring) + # Cap forward to avoid overlap with backward items in circular ring + max_forward = max(ring_len - 1 - backward, 0) + forward = min(forward, max_forward) + # Collect IDs with their offsets: negative=previous, positive=next items = [] for i in range(backward, 0, -1): diff --git a/make_post_sell/static/css/common.css b/make_post_sell/static/css/common.css index 5ff18ef..45c492b 100644 --- a/make_post_sell/static/css/common.css +++ b/make_post_sell/static/css/common.css @@ -1451,6 +1451,11 @@ textarea.markup-editor-textarea { display: none; } + /* Fresh mode: show overflow items that aren't watched */ + .related-content.fresh-mode .related-content-row.related-content-overflow:not(.related-content-row-watched) { + display: block; + } + /* Show the comments anchor link on mobile */ .related-content-comments-link, .product-comments-link { diff --git a/make_post_sell/static/js/watch.js b/make_post_sell/static/js/watch.js index ae3759f..ac6ca53 100644 --- a/make_post_sell/static/js/watch.js +++ b/make_post_sell/static/js/watch.js @@ -921,7 +921,8 @@ html += '' + offset + ''; html += ''; if (item.thumbnail_url) { - html += ''; + var lazyAttr = offset > 7 ? ' loading="lazy"' : ''; + html += ''; } else { html += ''; } diff --git a/make_post_sell/templates/snippets/related_content.j2 b/make_post_sell/templates/snippets/related_content.j2 index 770299c..9680c28 100644 --- a/make_post_sell/templates/snippets/related_content.j2 +++ b/make_post_sell/templates/snippets/related_content.j2 @@ -73,7 +73,7 @@ {{ offset }} {% if "thumbnail1" in related.extensions %} - + 7 %}loading="lazy" {% endif %}src="{{ request.app["bucket.secure_uploads.get_endpoint"] }}/{{ related.s3_path }}/thumbnail1?ts={{ related.updated_timestamp }}" /> {% else %} {% endif %} diff --git a/make_post_sell/views/content.py b/make_post_sell/views/content.py index 56c0a03..344d821 100644 --- a/make_post_sell/views/content.py +++ b/make_post_sell/views/content.py @@ -78,7 +78,7 @@ def content(request): from ..models.product import get_ring_related_products, get_related_products ring = product.shop.discovery_ring if ring: - related_products = get_ring_related_products(product, ring) + related_products = get_ring_related_products(product, ring, forward=len(ring)) else: related_products = get_related_products(product) diff --git a/make_post_sell/views/product.py b/make_post_sell/views/product.py index f613489..dbca046 100644 --- a/make_post_sell/views/product.py +++ b/make_post_sell/views/product.py @@ -98,7 +98,7 @@ def product(request): from ..models.product import get_ring_related_products, get_related_products ring = product.shop.discovery_ring if ring: - related_products = get_ring_related_products(product, ring) + related_products = get_ring_related_products(product, ring, forward=len(ring)) else: related_products = get_related_products(product) diff --git a/make_post_sell/views/watch.py b/make_post_sell/views/watch.py index e519108..0e6e5d7 100644 --- a/make_post_sell/views/watch.py +++ b/make_post_sell/views/watch.py @@ -106,7 +106,7 @@ def watch_json(request): # Use existing discovery ring — never recompute during a request ring = request.shop.discovery_ring if ring: - related = get_ring_related_products(product, ring) + related = get_ring_related_products(product, ring, forward=len(ring)) else: related = get_related_products(product)