notifications: Add 'none' to unread count options.

This commit is contained in:
Kanishk Kakar
2019-08-20 03:03:11 +05:30
committed by Tim Abbott
parent 330d065a69
commit e4f0d3d79b
4 changed files with 15 additions and 0 deletions

View File

@@ -50,6 +50,11 @@ function test_notifiable_count(home_unread_messages, expected_notifiable_count)
});
notifiable_counts = unread.get_notifiable_count();
assert.deepEqual(notifiable_counts, expected_notifiable_count);
set_global('page_params', {
desktop_icon_count_display: 3,
});
notifiable_counts = unread.get_notifiable_count();
assert.deepEqual(notifiable_counts, 0);
}
run_test('empty_counts_while_narrowed', () => {

View File

@@ -73,6 +73,10 @@ exports.desktop_icon_count_display_values = {
code: 2,
description: i18n.t("Private messages and mentions"),
},
none: {
code: 3,
description: i18n.t("None"),
},
};
function change_notification_setting(setting, setting_data, status_element) {

View File

@@ -552,9 +552,14 @@ exports.calculate_notifiable_count = function (res) {
var only_show_notifiable = page_params.desktop_icon_count_display ===
settings_notifications.desktop_icon_count_display_values.notifiable.code;
var no_notifications = page_params.desktop_icon_count_display ===
settings_notifications.desktop_icon_count_display_values.none.code;
if (only_show_notifiable) {
// DESKTOP_ICON_COUNT_DISPLAY_NOTIFIABLE
new_message_count = res.mentioned_message_count + res.private_message_count;
} else if (no_notifications) {
// DESKTOP_ICON_COUNT_DISPLAY_NONE
new_message_count = 0;
} else {
// DESKTOP_ICON_COUNT_DISPLAY_MESSAGES
new_message_count = res.home_unread_messages;

View File

@@ -836,6 +836,7 @@ class UserProfile(AbstractBaseUser, PermissionsMixin):
DESKTOP_ICON_COUNT_DISPLAY_MESSAGES = 1
DESKTOP_ICON_COUNT_DISPLAY_NOTIFIABLE = 2
DESKTOP_ICON_COUNT_DISPLAY_NONE = 3
desktop_icon_count_display = models.PositiveSmallIntegerField(
default=DESKTOP_ICON_COUNT_DISPLAY_MESSAGES) # type: int