typing_events: Make explicit call of narrow change handle function.

This commit is contained in:
Shubham Dhama
2018-08-06 21:39:51 +05:30
committed by Tim Abbott
parent e908da7831
commit b726cd4b3e
3 changed files with 9 additions and 9 deletions

View File

@@ -24,6 +24,7 @@ set_global('page_params', {});
set_global('search', {});
set_global('stream_list', {});
set_global('top_left_corner', {});
set_global('typing_events', {});
set_global('ui_util', {});
set_global('util', {});
set_global('unread_ops', {});
@@ -83,6 +84,7 @@ function test_helper() {
stub('search', 'update_button_visibility');
stub('stream_list', 'handle_narrow_activated');
stub('top_left_corner', 'handle_narrow_activated');
stub('typing_events', 'render_notifications_for_narrow');
stub('ui_util', 'change_tab_to');
stub('unread_ops', 'process_visible');
stub('compose', 'update_stream_button_for_stream');
@@ -217,6 +219,7 @@ run_test('basics', () => {
'compose_actions.on_narrow',
'top_left_corner.handle_narrow_activated',
'stream_list.handle_narrow_activated',
'typing_events.render_notifications_for_narrow',
'trigger event',
]);

View File

@@ -270,6 +270,7 @@ exports.activate = function (raw_operators, opts) {
top_left_corner.handle_narrow_activated(current_filter);
stream_list.handle_narrow_activated(current_filter);
typing_events.render_notifications_for_narrow();
$(document).trigger($.Event('narrow_activated.zulip', {msg_list: message_list.narrowed,
filter: current_filter,
@@ -613,6 +614,7 @@ function handle_post_narrow_deactivate_processes() {
compose.update_stream_button_for_stream();
message_edit.handle_narrow_deactivated();
widgetize.set_widgets_for_list();
typing_events.render_notifications_for_narrow();
$(document).trigger($.Event('narrow_deactivated.zulip', {msg_list: current_msg_list}));

View File

@@ -41,7 +41,7 @@ function get_users_typing_for_narrow() {
return typing_data.get_all_typists();
}
function render_notifications_for_narrow() {
exports.render_notifications_for_narrow = function () {
var user_ids = get_users_typing_for_narrow();
var users_typing = user_ids.map(people.get_person_from_user_id);
if (users_typing.length === 0) {
@@ -50,7 +50,7 @@ function render_notifications_for_narrow() {
$('#typing_notifications').html(templates.render('typing_notifications', {users: users_typing}));
$('#typing_notifications').show();
}
}
};
exports.hide_notification = function (event) {
var recipients = event.recipients.map(function (user) {
@@ -63,7 +63,7 @@ exports.hide_notification = function (event) {
var removed = typing_data.remove_typist(recipients, event.sender.user_id);
if (removed) {
render_notifications_for_narrow();
exports.render_notifications_for_narrow();
}
};
@@ -78,7 +78,7 @@ exports.display_notification = function (event) {
typing_data.add_typist(recipients, sender_id);
render_notifications_for_narrow();
exports.render_notifications_for_narrow();
typing_data.kickstart_inbound_timer(
recipients,
@@ -88,11 +88,6 @@ exports.display_notification = function (event) {
}
);
};
$(document).on('narrow_activated.zulip', render_notifications_for_narrow);
$(document).on('narrow_deactivated.zulip', render_notifications_for_narrow);
return exports;
}());