subs: Call `filter.fix_stream_params` when updating stream name.

Previously the navbar did not live update the stream name correctly.

The correct behaviour was blocked on the `_stream_name` prop on the
filter object. The original purpose for maintaining this prop was
convenience, to reduce calls to `subs`, however, it would become
inconsistent with the value from `subs` on stream rename.

In this commit we add a call to `filter.fix_stream_params` in
`subs.update_stream_name`. This fixes live rerendering in the navbar,
despite the fact that searchbox in the nav (and the filter object via
`filter.operands("stream")[0]`) will still have the old name.

This is a slightly hacky way of masking some of the problems in the
Filter object. However, it should make do until we migrate to a stream
ID based state there.

Fixes: #14728.
This commit is contained in:
YashRE42 2020-06-08 19:53:43 +00:00 committed by Tim Abbott
parent 96e272081d
commit e389129f34
1 changed files with 10 additions and 5 deletions

View File

@ -143,12 +143,17 @@ exports.update_stream_name = function (sub, new_name) {
// Update navbar stream name if needed
const filter = narrow_state.filter();
if (filter && filter.operands("stream")[0] === old_name) {
// TODO: This doesn't work, because the `filter` object
// represents the stream by name and hasn't been updated.
// This works, but it relies on `filter.fix_stream_params` masking
// some bad behaviour in the Filter object. In particular, the fact
// that the Filter object relies on the search box which doesn't
// rename the currently focused stream.
//
// This will likely be fixed automatically as we migrate to
// using search pills and then a stream ID based
// representation of the stream in Filter objects.
// This will likely be improved as we migrate to using search pills
// and then a stream ID based representation of the stream in Filter.
// update the stream_params stored in the filter object
filter.fix_stream_params();
// use these to update the navbar
tab_bar.render_title_area();
}
};