recent topics: Fix live update on muted_topics events.

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.
This commit is contained in:
Abhijeet Prasad Bodas 2021-03-28 13:02:21 +05:30 committed by Tim Abbott
parent ace54f3c3b
commit f725711ff2
1 changed files with 1 additions and 0 deletions

View File

@ -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();
}