streams: Fix stream color synchronization.

Previously, when a new stream was created on a client other than the
current one, the browser would first receive the "stream_created"
event, and make up a client-side display color at that time to use in
the "stream settings" view (it doesn't yet know the color that was
selected when the user was actually subscribed, because it doesn't
even know yet that the user is being subscribed to this stream), and
then moments after it'll receive a "susbcribe" event letting the
client know that the user is subscribed (and specifying the color to
use).

However, due to an argument not being passed through properly and a
missing rerender, we were not properly updating either the data
structures or doing a stream colors rerender in order to show the new
color.

This fixes the issue reported in
https://chat.zulip.org/#narrow/stream/48-mobile/subject/stream.20colors/near/660170
This commit is contained in:
Tim Abbott
2018-11-09 16:57:10 -08:00
parent fe931d9b66
commit 2c06615909
3 changed files with 21 additions and 9 deletions

View File

@@ -100,8 +100,9 @@ exports.mark_subscribed = function (sub, subscribers, color) {
}
// If the backend sent us a color, use that
if (color !== undefined) {
if (color !== undefined && sub.color !== color) {
sub.color = color;
stream_color.update_stream_color(sub, color, {update_historical: true});
} else if (sub.color === undefined) {
// If the backend didn't, and we have a color already, send
// the backend that color. It's not clear this code path is