recent_topics: Fix annoying flicker on rerendering.

We were apparently not using the ListWidget API for replacing the
content of a widget without removing the whole thing from the DOM and
replacing it.

Unless ListWidget has unexpected bugs, this should have the exact same
result as the previous logic, with much a nicer user experience.
This commit is contained in:
Tim Abbott
2021-05-12 08:49:58 -07:00
committed by Tim Abbott
parent 4dae2c53fb
commit b0f8bbfbd4
2 changed files with 132 additions and 6 deletions

View File

@@ -584,8 +584,19 @@ export function complete_rerender() {
if (!is_visible()) {
return;
}
// Prepare header
// Update header
load_filters();
show_selected_filters();
// Show topics list
const mapped_topic_values = Array.from(get().values()).map((value) => value);
if (topics_widget) {
topics_widget.replace_list_data(mapped_topic_values);
return;
}
const rendered_body = render_recent_topics_body({
filter_participated: filters.has("participated"),
filter_unread: filters.has("unread"),
@@ -593,13 +604,8 @@ export function complete_rerender() {
search_val: $("#recent_topics_search").val() || "",
});
$("#recent_topics_table").html(rendered_body);
show_selected_filters();
// Show topics list
const container = $("#recent_topics_table table tbody");
container.empty();
const mapped_topic_values = Array.from(get().values()).map((value) => value);
topics_widget = ListWidget.create(container, mapped_topic_values, {
name: "recent_topics_table",
parent_container: $("#recent_topics_table"),