mirror of https://github.com/zulip/zulip.git
activity: Fix buddy_list unread count not being updated instantly.
While rest of the app has ported to the new system of updating unread_counts `activity` was not ported. This resulted in unread count in buddy list not being updated when new PMs arrive.
This commit is contained in:
parent
06af1715cb
commit
e5acbf9498
|
@ -261,13 +261,11 @@ function buddy_list_add(user_id, stub) {
|
||||||
}
|
}
|
||||||
|
|
||||||
test_ui("PM_update_dom_counts", () => {
|
test_ui("PM_update_dom_counts", () => {
|
||||||
const value = $.create("alice-value");
|
const count = $.create("alice-unread-count");
|
||||||
const count = $.create("alice-count");
|
|
||||||
const pm_key = alice.user_id.toString();
|
const pm_key = alice.user_id.toString();
|
||||||
const li = $.create("alice stub");
|
const li = $.create("alice stub");
|
||||||
buddy_list_add(pm_key, li);
|
buddy_list_add(pm_key, li);
|
||||||
count.set_find_results(".value", value);
|
li.set_find_results(".unread_count", count);
|
||||||
li.set_find_results(".count", count);
|
|
||||||
count.set_parents_result("li", li);
|
count.set_parents_result("li", li);
|
||||||
|
|
||||||
const counts = new Map();
|
const counts = new Map();
|
||||||
|
@ -275,14 +273,12 @@ test_ui("PM_update_dom_counts", () => {
|
||||||
li.addClass("user_sidebar_entry");
|
li.addClass("user_sidebar_entry");
|
||||||
|
|
||||||
activity.update_dom_with_unread_counts({pm_count: counts});
|
activity.update_dom_with_unread_counts({pm_count: counts});
|
||||||
assert(li.hasClass("user-with-count"));
|
assert.equal(count.text(), "5");
|
||||||
assert.equal(value.text(), "5");
|
|
||||||
|
|
||||||
counts.set(pm_key, 0);
|
counts.set(pm_key, 0);
|
||||||
|
|
||||||
activity.update_dom_with_unread_counts({pm_count: counts});
|
activity.update_dom_with_unread_counts({pm_count: counts});
|
||||||
assert(!li.hasClass("user-with-count"));
|
assert.equal(count.text(), "");
|
||||||
assert.equal(value.text(), "");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test_ui("handlers", (override) => {
|
test_ui("handlers", (override) => {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import * as people from "./people";
|
||||||
import * as pm_list from "./pm_list";
|
import * as pm_list from "./pm_list";
|
||||||
import * as popovers from "./popovers";
|
import * as popovers from "./popovers";
|
||||||
import * as presence from "./presence";
|
import * as presence from "./presence";
|
||||||
|
import * as ui_util from "./ui_util";
|
||||||
import {UserSearch} from "./user_search";
|
import {UserSearch} from "./user_search";
|
||||||
import * as user_status from "./user_status";
|
import * as user_status from "./user_status";
|
||||||
import * as watchdog from "./watchdog";
|
import * as watchdog from "./watchdog";
|
||||||
|
@ -51,21 +52,6 @@ export function set_new_user_input(value) {
|
||||||
new_user_input = value;
|
new_user_input = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_pm_count_in_dom(count_span, value_span, count) {
|
|
||||||
const li = count_span.parents("li");
|
|
||||||
|
|
||||||
if (count === 0) {
|
|
||||||
count_span.hide();
|
|
||||||
li.removeClass("user-with-count");
|
|
||||||
value_span.text("");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
count_span.show();
|
|
||||||
li.addClass("user-with-count");
|
|
||||||
value_span.text(count);
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_pm_list_item(user_id) {
|
function get_pm_list_item(user_id) {
|
||||||
return buddy_list.find_li({
|
return buddy_list.find_li({
|
||||||
key: user_id,
|
key: user_id,
|
||||||
|
@ -73,9 +59,8 @@ function get_pm_list_item(user_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_pm_count(user_ids_string, count) {
|
function set_pm_count(user_ids_string, count) {
|
||||||
const count_span = get_pm_list_item(user_ids_string).find(".count");
|
const pm_li = get_pm_list_item(user_ids_string);
|
||||||
const value_span = count_span.find(".value");
|
ui_util.update_unread_count_in_dom(pm_li, count);
|
||||||
update_pm_count_in_dom(count_span, value_span, count);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function update_dom_with_unread_counts(counts) {
|
export function update_dom_with_unread_counts(counts) {
|
||||||
|
|
Loading…
Reference in New Issue