streams: Fix default streams list not updating on deactivation.

If you deactivated a default stream, we would correctly remove it from
the list of default streams in the organization.  However, we did not
call `send_event`, so browsers would still display it as a default
stream until the next reload.

This fixes that issue by calling do_remove_default_stream instead of
doing the database query directly.
This commit is contained in:
Tim Abbott 2017-06-04 10:34:48 -07:00
parent eb25c6be87
commit d21756c396
1 changed files with 4 additions and 1 deletions

View File

@ -585,7 +585,10 @@ def do_deactivate_stream(stream, log=True):
stream.name = new_name[:Stream.MAX_NAME_LENGTH]
stream.save()
DefaultStream.objects.filter(realm=stream.realm, stream=stream).delete()
# If this is a default stream, remove it, properly sending a
# notification to browser clients.
if DefaultStream.objects.filter(realm=stream.realm, stream=stream).exists():
do_remove_default_stream(stream)
# Remove the old stream information from remote cache.
old_cache_key = get_stream_cache_key(old_name, stream.realm)