mirror of https://github.com/zulip/zulip.git
buddy_list: Simplify logic to update empty list placeholders.
Because we regularly change what we want the placeholder text to be, as the user enters and exits search, it's simpler to just not use `data-search-results-empty` and set up the placeholder from the buddy list code directly. Previously we were trying to sometimes use `data-search-results-empty` and sometimes set it directly, which is more confusing and complex.
This commit is contained in:
parent
d0dc33d8da
commit
f157bfe181
|
@ -330,27 +330,27 @@ export class BuddyList extends BuddyListConf {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#buddy-list-users-matching-view").attr(
|
function add_or_update_empty_list_placeholder(selector: string, message: string): void {
|
||||||
"data-search-results-empty",
|
if (
|
||||||
matching_view_empty_list_message,
|
$(selector).children().length === 0 ||
|
||||||
);
|
$(`${selector} .empty-list-message`).length
|
||||||
if ($("#buddy-list-users-matching-view .empty-list-message").length) {
|
) {
|
||||||
const empty_list_widget_html = render_empty_list_widget_for_list({
|
const empty_list_widget_html = render_empty_list_widget_for_list({
|
||||||
empty_list_message: matching_view_empty_list_message,
|
empty_list_message: message,
|
||||||
});
|
});
|
||||||
$("#buddy-list-users-matching-view").html(empty_list_widget_html);
|
$(selector).html(empty_list_widget_html);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#buddy-list-other-users").attr(
|
add_or_update_empty_list_placeholder(
|
||||||
"data-search-results-empty",
|
"#buddy-list-users-matching-view",
|
||||||
|
matching_view_empty_list_message,
|
||||||
|
);
|
||||||
|
|
||||||
|
add_or_update_empty_list_placeholder(
|
||||||
|
"#buddy-list-other-users",
|
||||||
other_users_empty_list_message,
|
other_users_empty_list_message,
|
||||||
);
|
);
|
||||||
if ($("#buddy-list-other-users .empty-list-message").length) {
|
|
||||||
const empty_list_widget_html = render_empty_list_widget_for_list({
|
|
||||||
empty_list_message: other_users_empty_list_message,
|
|
||||||
});
|
|
||||||
$("#buddy-list-other-users").html(empty_list_widget_html);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update_section_header_counts(): void {
|
update_section_header_counts(): void {
|
||||||
|
|
|
@ -21,15 +21,15 @@
|
||||||
<div id="buddy_list_wrapper" class="scrolling_list" data-simplebar data-simplebar-tab-index="-1">
|
<div id="buddy_list_wrapper" class="scrolling_list" data-simplebar data-simplebar-tab-index="-1">
|
||||||
<div id="buddy-list-participants-container" class="buddy-list-section-container">
|
<div id="buddy-list-participants-container" class="buddy-list-section-container">
|
||||||
<div class="buddy-list-subsection-header"></div>
|
<div class="buddy-list-subsection-header"></div>
|
||||||
<ul id="buddy-list-participants" class="buddy-list-section" data-search-results-empty="{{t 'None.' }}"></ul>
|
<ul id="buddy-list-participants" class="buddy-list-section"></ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="buddy-list-users-matching-view-container" class="buddy-list-section-container">
|
<div id="buddy-list-users-matching-view-container" class="buddy-list-section-container">
|
||||||
<div class="buddy-list-subsection-header"></div>
|
<div class="buddy-list-subsection-header"></div>
|
||||||
<ul id="buddy-list-users-matching-view" class="buddy-list-section" data-search-results-empty="{{t 'None.' }}"></ul>
|
<ul id="buddy-list-users-matching-view" class="buddy-list-section"></ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="buddy-list-other-users-container" class="buddy-list-section-container">
|
<div id="buddy-list-other-users-container" class="buddy-list-section-container">
|
||||||
<div class="buddy-list-subsection-header"></div>
|
<div class="buddy-list-subsection-header"></div>
|
||||||
<ul id="buddy-list-other-users" class="buddy-list-section" data-search-results-empty="{{t 'None.' }}"></ul>
|
<ul id="buddy-list-other-users" class="buddy-list-section"></ul>
|
||||||
</div>
|
</div>
|
||||||
<div id="buddy_list_wrapper_padding"></div>
|
<div id="buddy_list_wrapper_padding"></div>
|
||||||
<div class="right-sidebar-shortcuts">
|
<div class="right-sidebar-shortcuts">
|
||||||
|
|
|
@ -731,7 +731,6 @@ test("realm_presence_disabled", ({override}) => {
|
||||||
test("redraw_muted_user", () => {
|
test("redraw_muted_user", () => {
|
||||||
muted_users.add_muted_user(mark.user_id);
|
muted_users.add_muted_user(mark.user_id);
|
||||||
activity_ui.redraw_user(mark.user_id);
|
activity_ui.redraw_user(mark.user_id);
|
||||||
assert.equal($("#buddy-list-users-matching-view").html(), "never-been-set");
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("update_presence_info", ({override, override_rewire}) => {
|
test("update_presence_info", ({override, override_rewire}) => {
|
||||||
|
|
Loading…
Reference in New Issue