-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add lazy loading for media list #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| {% load i18n %} | ||
| {# This partial creates a "Load more" trigger that uses HTMX infinite scroll #} | ||
| {% if page_obj.has_next %} | ||
| {% if view_mode == 'grid' %} | ||
| <div id="load-more-trigger" | ||
| hx-get="{% url 'load_more_media' %}?page={{ page_obj.next_page_number }}" | ||
| hx-trigger="revealed" | ||
| hx-swap="outerHTML" | ||
| hx-include="#view-mode-input, #sort, #type, #status, #score, #review-from, #review-to, [name='search']" | ||
| class="col-span-full flex justify-center py-4"> | ||
| {% include "partials/spinner.html" with size="lg" show_text=True text=_("Loading more...") inline=True %} | ||
| </div> | ||
| {% else %} | ||
| <tr id="load-more-trigger" | ||
| hx-get="{% url 'load_more_media' %}?page={{ page_obj.next_page_number }}" | ||
| hx-trigger="revealed" | ||
| hx-swap="outerHTML" | ||
| hx-include="#view-mode-input, #sort, #type, #status, #score, #review-from, #review-to, [name='search']"> | ||
| <td colspan="8" class="text-center py-4"> | ||
| {% include "partials/spinner.html" with size="lg" show_text=True text=_("Loading more...") inline=True %} | ||
| </td> | ||
| </tr> | ||
| {% endif %} | ||
| {% endif %} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| {% load i18n %} | ||
| {# This partial renders media items for a single page + the load more trigger #} | ||
| {% include "partials/media-items.html" %} | ||
| {% include "partials/load-more-trigger.html" %} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,10 +1,10 @@ | ||
| {% load i18n %} | ||
| <div id="media-list"> | ||
| {% if media_list %} | ||
| {% if page_obj %} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, find the media-items-page.html file
find . -name "media-items-page.html" -o -name "media-items*" | head -20Repository: PascalRepond/datakult Length of output: 153 🏁 Script executed: # Check the media-list.html file to see the full context
cat -n src/templates/partials/media-list.htmlRepository: PascalRepond/datakult Length of output: 1567 🏁 Script executed: # Search for empty state handling patterns in template files
rg "No media|empty|if.*object_list|if.*count" src/templates/partials/ -A 2 -B 2Repository: PascalRepond/datakult Length of output: 914 🏁 Script executed: # Check the media-items-page.html file
cat -n src/templates/partials/media-items-page.htmlRepository: PascalRepond/datakult Length of output: 279 🏁 Script executed: # Also check media-items.html for reference
cat -n src/templates/partials/media-items.htmlRepository: PascalRepond/datakult Length of output: 5046 Check the pagination condition to properly handle empty states. The condition changed from Change the condition to 🤖 Prompt for AI Agents |
||
| {% if view_mode == 'grid' %} | ||
| {# Grid view - Cards layout #} | ||
| <div class="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4 mt-4" | ||
| id="media-container">{% include "partials/media-items.html" %}</div> | ||
| id="media-container">{% include "partials/media-items-page.html" %}</div> | ||
| {% else %} | ||
| {# List view - Table layout #} | ||
| <div class="overflow-x-auto"> | ||
|
|
@@ -22,7 +22,7 @@ | |
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| {% include "partials/media-items.html" %} | ||
| {% include "partials/media-items-page.html" %} | ||
| </tbody> | ||
| </table> | ||
| </div> | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,18 @@ | ||
| <div id="spinner" | ||
| class="loading loading-spinner loading-xl text-primary htmx-indicator"></div> | ||
| {% comment %} | ||
| Spinner component - Unified loading indicator | ||
| Parameters: | ||
| - id: HTML id attribute (default: "spinner") | ||
| - size: "xs", "sm", "md", "lg", "xl" (default: "md") | ||
| - color: "primary", "secondary", "accent", "neutral" (default: "primary") | ||
| - htmx_indicator: boolean - add htmx-indicator class (default: false) | ||
| - show_text: boolean - show loading text (default: false) | ||
| - text: custom loading text (default: "Loading...") | ||
| - inline: boolean - display inline with text (default: false) | ||
| {% endcomment %} | ||
| {% load i18n %} | ||
| <div {% if id %}id="{{ id }}"{% endif %} | ||
| class="loading loading-spinner loading-{{ size|default:'md' }} text-{{ color|default:'primary' }}{% if htmx_indicator %} htmx-indicator{% endif %}{% if inline %} inline-block{% endif %}"> | ||
| </div> | ||
| {% if show_text %} | ||
| <span class="ml-2">{{ text|default:_("Loading...") }}</span> | ||
| {% endif %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: PascalRepond/datakult
Length of output: 3928
Add contributor filter to hx-include to preserve filter state on infinite scroll.
The HTMX configuration correctly implements infinite scroll with
hx-trigger="revealed"andhx-swap="outerHTML", and most filter state is properly preserved. However, thehx-includeattribute is missing the contributor filter. When users apply a contributor filter and scroll to load more items, the contributor selection will not be sent in subsequent requests, causing the pagination to ignore that filter.Add
#contributorto thehx-includelist:Updated hx-include
🤖 Prompt for AI Agents