Skip to content
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

Fix 956 unread private messages count #1449

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
704d1f1
html fix
WojtekReu May 1, 2019
dd29637
Revert "html fix"
WojtekReu May 1, 2019
a57113f
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu May 1, 2019
1978fc2
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu May 3, 2019
3148251
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu May 4, 2019
ada46c5
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu May 14, 2019
c6da7e4
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu May 15, 2019
3f0c931
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu May 20, 2019
89fc508
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu May 21, 2019
48a67ee
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu Jun 8, 2019
b8d5f72
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu Jun 9, 2019
a4d7ba2
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu Jun 11, 2019
049a944
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu Jul 31, 2019
4cb1d76
Merge remote-tracking branch 'rafalp/master'
WojtekReu Aug 19, 2019
9c24afa
Merge remote-tracking branch 'rafalp/master'
WojtekReu Jun 28, 2020
2ab2f13
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu Jan 16, 2023
5fa79d9
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu Jan 23, 2023
a6a885c
Merge branch 'master' of github.com:rafalp/Misago
WojtekReu Jan 30, 2023
9e506c6
fix: recount unread private messages
WojtekReu Jan 31, 2023
0709554
fix: recount unread private messages when last user's post is after c…
WojtekReu Jan 31, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion misago/readtracker/threadstracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .cutoffdate import get_cutoff_date


def make_read_aware(request, threads):
def make_read_aware(request, threads, update_unread_private_threads=False):
if not threads:
return

Expand All @@ -29,6 +29,9 @@ def make_read_aware(request, threads):

unread_threads = list(queryset)

if update_unread_private_threads:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic should be part of separate utility.

request.user.unread_private_threads = len(unread_threads)

for thread in threads:
if thread.pk in unread_threads:
thread.is_read = False
Expand Down
13 changes: 12 additions & 1 deletion misago/threads/viewmodels/threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,22 @@ def __init__(self, request, category, list_type, start=0):
except (EmptyPage, InvalidPage):
raise Http404()

update_unread_private_threads = False
if list_page.first:
pinned_threads = list(
self.get_pinned_threads(
base_queryset, category_model, threads_categories
)
)
threads = list(pinned_threads) + list(list_page.object_list)
if category_model.name == "Private":
if not list_page.has_next():
update_unread_private_threads = True
elif threads and threads[-1].last_post_on < get_cutoff_date(
request.settings, request.user
):
update_unread_private_threads = True

else:
threads = list(list_page.object_list)

Expand All @@ -89,7 +98,9 @@ def __init__(self, request, category, list_type, start=0):
thread.is_read = False
thread.is_new = True
else:
threadstracker.make_read_aware(request, threads)
threadstracker.make_read_aware(
request, threads, update_unread_private_threads
)

self.filter_threads(request, threads)

Expand Down