Skip to content

Commit

Permalink
recent topics: Fix live update on muted_topics events.
Browse files Browse the repository at this point in the history
Previously, the recent-topics view did not update when the webapp
received `muted_topics` events.

The final state was correct **only** on the client which was used to
mute/unmute the topic, because we update the UI even before sending
the request to the server to mute/unmute the topic.

This commit fixes that by rerendering the recent-topics table when the
client receives `muted_topics` events.  While doing so can be
expensive, it is likely unavoidable, because we may want to even
remove the topic from the recent-topics table, and we don't know
exactly which topic was affected (we just get an updated list of all
muted topics from the event).

Even though rerendering is expensive, it should not affect the user
experience, because a rerender will be trriggered only in the clients
which did not do the (un)muting (and hence, the user was probably not
interacting with these clients when the event was received). The
`last_topic_update` variable makes sure that this is the case.
  • Loading branch information
abhijeetbodas2001 authored and timabbott committed Apr 6, 2021
1 parent ace54f3 commit f725711
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions static/js/muting_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export function rerender_on_topic_update() {
// re-doing a mute or unmute is a pretty recoverable thing.

stream_list.update_streams_sidebar();
recent_topics.complete_rerender();
if (message_lists.current.excludes_muted_topics) {
message_lists.current.update_muting_and_rerender();
}
Expand Down

0 comments on commit f725711

Please sign in to comment.