mirror of
https://github.com/zulip/zulip.git
synced 2025-11-08 07:52:19 +00:00
Eliminate approximate_unread_count().
We use page_params.unread_msgs.count in the web app instead. Fixes #1300.
This commit is contained in:
@@ -82,7 +82,7 @@ function consider_bankruptcy() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var now = new XDate(true).getTime() / 1000;
|
var now = new XDate(true).getTime() / 1000;
|
||||||
if ((page_params.unread_count > 500) &&
|
if ((page_params.unread_msgs.count > 500) &&
|
||||||
(now - page_params.furthest_read_time > 60 * 60 * 24 * 2)) { // 2 days.
|
(now - page_params.furthest_read_time > 60 * 60 * 24 * 2)) { // 2 days.
|
||||||
var unread_info = templates.render('bankruptcy_modal',
|
var unread_info = templates.render('bankruptcy_modal',
|
||||||
{unread_count: page_params.unread_count});
|
{unread_count: page_params.unread_count});
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ class HomeTest(ZulipTestCase):
|
|||||||
"test_suite",
|
"test_suite",
|
||||||
"timezone",
|
"timezone",
|
||||||
"twenty_four_hour_time",
|
"twenty_four_hour_time",
|
||||||
"unread_count",
|
|
||||||
"unread_msgs",
|
"unread_msgs",
|
||||||
"unsubscribed",
|
"unsubscribed",
|
||||||
"use_websockets",
|
"use_websockets",
|
||||||
|
|||||||
@@ -58,22 +58,6 @@ def accounts_accept_terms(request):
|
|||||||
'special_message_template': special_message_template},
|
'special_message_template': special_message_template},
|
||||||
)
|
)
|
||||||
|
|
||||||
def approximate_unread_count(user_profile):
|
|
||||||
# type: (UserProfile) -> int
|
|
||||||
not_in_home_view_recipients = [sub.recipient.id for sub in
|
|
||||||
Subscription.objects.filter(
|
|
||||||
user_profile=user_profile, in_home_view=False)]
|
|
||||||
|
|
||||||
# TODO: We may want to exclude muted messages from this count.
|
|
||||||
# It was attempted in the past, but the original attempt
|
|
||||||
# was broken. When we re-architect muting, we may
|
|
||||||
# want to to revisit this (see git issue #1019).
|
|
||||||
return UserMessage.objects.filter(
|
|
||||||
user_profile=user_profile, message_id__gt=user_profile.pointer).exclude(
|
|
||||||
message__recipient__type=Recipient.STREAM,
|
|
||||||
message__recipient__id__in=not_in_home_view_recipients).exclude(
|
|
||||||
flags=UserMessage.flags.read).count()
|
|
||||||
|
|
||||||
def sent_time_in_epoch_seconds(user_message):
|
def sent_time_in_epoch_seconds(user_message):
|
||||||
# type: (UserMessage) -> Optional[float]
|
# type: (UserMessage) -> Optional[float]
|
||||||
# user_message is a UserMessage object.
|
# user_message is a UserMessage object.
|
||||||
@@ -209,7 +193,6 @@ def home_real(request):
|
|||||||
needs_tutorial = needs_tutorial,
|
needs_tutorial = needs_tutorial,
|
||||||
first_in_realm = first_in_realm,
|
first_in_realm = first_in_realm,
|
||||||
prompt_for_invites = prompt_for_invites,
|
prompt_for_invites = prompt_for_invites,
|
||||||
unread_count = approximate_unread_count(user_profile),
|
|
||||||
furthest_read_time = sent_time_in_epoch_seconds(latest_read),
|
furthest_read_time = sent_time_in_epoch_seconds(latest_read),
|
||||||
has_mobile_devices = num_push_devices_for_user(user_profile) > 0,
|
has_mobile_devices = num_push_devices_for_user(user_profile) > 0,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user