From afd00cc67a3649b6725e5955d2f0d8c7a1a8b8f9 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 16 Oct 2021 16:38:02 +1100 Subject: [PATCH] improve group removal flow Use .save() twice, but with broadcast=False on the second update. This is more efficient than doing a query and update() and avoids the duplicate AP broadcast. --- bookwyrm/views/list.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bookwyrm/views/list.py b/bookwyrm/views/list.py index 5dae128e..97eaf9d6 100644 --- a/bookwyrm/views/list.py +++ b/bookwyrm/views/list.py @@ -58,7 +58,8 @@ class Lists(View): book_list = form.save() # list should not have a group if it is not group curated if not book_list.curation == "group": - models.List.objects.filter(id=book_list.id).update(group=None) + book_list.group = None + book_list.save(broadcast=False) return redirect(book_list.local_path) @@ -193,7 +194,9 @@ class List(View): return redirect("list", book_list.id) book_list = form.save() if not book_list.curation == "group": - models.List.objects.filter(id=book_list.id).update(group=None) + book_list.group = None + book_list.save(broadcast=False) + return redirect(book_list.local_path)