Skip to content

Commit

Permalink
99 - Long user watch list causes page loading issues (#6514)
Browse files Browse the repository at this point in the history
* 99 - Long user watch list causes page loading issues
* Added pagination to view and template

* Ensure ordering is also by id
  • Loading branch information
smithellis authored Feb 19, 2025
1 parent c10de5d commit 9baae51
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions kitsune/users/jinja2/users/edit_watches.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ <h1 class="sumo-page-heading">{{ title }}</h1>
<button class="sumo-button primary-button button-lg" type="submit">{{ _('Update') }}</button>
</div>
</form>
{{ watch_list|paginator }}
{% else %}
<p>{{ _('You are not currently watching anything.') }}</p>
{% endif %}
Expand Down
4 changes: 3 additions & 1 deletion kitsune/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def edit_contribution_area(request):
@require_http_methods(["GET", "POST"])
def edit_watch_list(request):
"""Edit watch list"""
watches = Watch.objects.filter(user=request.user).order_by("content_type")
watches = Watch.objects.filter(user=request.user).order_by("content_type", "id")

watch_list = []
for item in watches:
Expand All @@ -302,6 +302,8 @@ def edit_watch_list(request):
else:
watch_list.append(item)

watch_list = paginate(request, watch_list)

if request.method == "POST":
for item in watch_list:
item.is_active = "watch_%s" % item.id in request.POST
Expand Down

0 comments on commit 9baae51

Please sign in to comment.