2013-05-06 02:54:15 +02:00
|
|
|
var stream_list = (function () {
|
|
|
|
|
|
|
|
var exports = {};
|
|
|
|
|
2013-05-16 23:40:07 +02:00
|
|
|
var last_private_message_count = 0;
|
2013-05-31 19:07:59 +02:00
|
|
|
var last_mention_count = 0;
|
2013-05-07 19:07:05 +02:00
|
|
|
var previous_sort_order;
|
2013-05-16 23:40:07 +02:00
|
|
|
|
2013-05-06 02:54:15 +02:00
|
|
|
exports.sort_narrow_list = function () {
|
2013-08-15 21:11:07 +02:00
|
|
|
var streams = stream_data.subscribed_streams();
|
2013-05-06 23:36:22 +02:00
|
|
|
if (streams.length === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var sort_recent = (streams.length > 40);
|
|
|
|
|
2013-07-05 17:43:56 +02:00
|
|
|
streams.sort(function (a, b) {
|
2013-05-06 02:54:15 +02:00
|
|
|
if (sort_recent) {
|
2013-08-07 23:56:51 +02:00
|
|
|
if (recent_subjects.has(b) && ! recent_subjects.has(a)) {
|
2013-05-06 02:54:15 +02:00
|
|
|
return 1;
|
2013-08-07 23:56:51 +02:00
|
|
|
} else if (! recent_subjects.has(b) && recent_subjects.has(a)) {
|
2013-05-06 02:54:15 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2013-05-06 23:36:22 +02:00
|
|
|
return util.strcmp(a, b);
|
2013-05-06 02:54:15 +02:00
|
|
|
});
|
|
|
|
|
2013-05-07 19:07:05 +02:00
|
|
|
if (previous_sort_order !== undefined
|
|
|
|
&& util.array_compare(previous_sort_order, streams)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
previous_sort_order = streams;
|
|
|
|
|
2013-05-06 23:36:22 +02:00
|
|
|
var parent = $('#stream_filters');
|
2013-05-06 02:54:15 +02:00
|
|
|
parent.empty();
|
|
|
|
|
2013-05-06 23:36:22 +02:00
|
|
|
var elems = [];
|
2013-07-30 00:35:44 +02:00
|
|
|
_.each(streams, function (stream) {
|
2013-08-15 21:11:07 +02:00
|
|
|
var li = $(stream_data.get_sub(stream).sidebar_li);
|
2013-05-06 02:54:15 +02:00
|
|
|
if (sort_recent) {
|
2013-08-07 23:56:51 +02:00
|
|
|
if (! recent_subjects.has(stream)) {
|
2013-05-06 23:36:22 +02:00
|
|
|
li.addClass('inactive_stream');
|
2013-05-06 02:54:15 +02:00
|
|
|
} else {
|
2013-05-06 23:36:22 +02:00
|
|
|
li.removeClass('inactive_stream');
|
2013-05-06 02:54:15 +02:00
|
|
|
}
|
|
|
|
}
|
2013-05-06 23:36:22 +02:00
|
|
|
elems.push(li.get(0));
|
2013-05-06 02:54:15 +02:00
|
|
|
});
|
2013-05-06 23:36:22 +02:00
|
|
|
$(elems).appendTo(parent);
|
2013-05-06 02:54:15 +02:00
|
|
|
};
|
|
|
|
|
2013-06-07 16:56:05 +02:00
|
|
|
function iterate_to_find(selector, name_to_find, context) {
|
2013-07-30 00:35:44 +02:00
|
|
|
var lowercase_name = name_to_find.toLowerCase();
|
|
|
|
var found = _.find($(selector, context), function (elem) {
|
2013-08-03 00:18:04 +02:00
|
|
|
return $(elem).attr('data-name').toLowerCase() === lowercase_name;
|
2013-05-06 02:54:15 +02:00
|
|
|
});
|
2013-07-30 00:35:44 +02:00
|
|
|
return found ? $(found) : $();
|
2013-05-06 02:54:15 +02:00
|
|
|
}
|
|
|
|
|
2013-06-05 20:29:31 +02:00
|
|
|
// TODO: Now that the unread count functions support the user sidebar
|
|
|
|
// as well, we probably should consider moving them to a different file.
|
2013-05-06 22:18:01 +02:00
|
|
|
function get_filter_li(type, name) {
|
2013-05-06 02:54:15 +02:00
|
|
|
if (type === 'stream') {
|
|
|
|
return $("#stream_sidebar_" + subs.stream_id(name));
|
2013-06-05 20:29:31 +02:00
|
|
|
} else if (type === "private") {
|
2013-08-21 20:52:27 +02:00
|
|
|
return $("li.user_sidebar_entry[data-email='" + name + "']");
|
2013-05-06 02:54:15 +02:00
|
|
|
}
|
|
|
|
return iterate_to_find("#" + type + "_filters > li", name);
|
2013-05-06 22:18:01 +02:00
|
|
|
}
|
2013-05-06 02:54:15 +02:00
|
|
|
|
2013-05-06 22:18:01 +02:00
|
|
|
function get_subject_filter_li(stream, subject) {
|
|
|
|
var stream_li = get_filter_li('stream', stream);
|
2013-05-06 02:54:15 +02:00
|
|
|
return iterate_to_find(".expanded_subjects li", subject, stream_li);
|
2013-05-06 22:18:01 +02:00
|
|
|
}
|
2013-05-06 02:54:15 +02:00
|
|
|
|
2013-06-12 00:07:35 +02:00
|
|
|
exports.set_in_home_view = function (stream, in_home) {
|
|
|
|
var li = get_filter_li('stream', stream);
|
|
|
|
if (in_home) {
|
|
|
|
li.removeClass("out_of_home_view");
|
|
|
|
} else {
|
|
|
|
li.addClass("out_of_home_view");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-10-21 22:26:19 +02:00
|
|
|
function build_narrow_filter(name, type) {
|
2013-05-30 20:50:32 +02:00
|
|
|
var args = {name: name,
|
|
|
|
id: subs.stream_id(name),
|
|
|
|
uri: narrow.by_stream_uri(name),
|
2013-08-15 21:11:07 +02:00
|
|
|
not_in_home_view: (stream_data.in_home_view(name) === false),
|
|
|
|
invite_only: stream_data.get_sub(name).invite_only,
|
2013-08-27 21:05:32 +02:00
|
|
|
color: stream_data.get_color(name)
|
|
|
|
};
|
|
|
|
args.dark_background = stream_color.get_color_class(args.color);
|
2013-06-12 18:03:16 +02:00
|
|
|
var list_item = $(templates.render('stream_sidebar_row', args));
|
2013-05-06 02:54:15 +02:00
|
|
|
$("#" + type + "_filters").append(list_item);
|
2013-05-06 23:36:22 +02:00
|
|
|
return list_item;
|
2013-05-06 22:18:01 +02:00
|
|
|
}
|
2013-05-06 02:54:15 +02:00
|
|
|
|
2013-10-21 22:26:19 +02:00
|
|
|
// Adds the sidebar stream name that, when clicked,
|
|
|
|
// narrows to that stream
|
|
|
|
function add_narrow_filter(name, type) {
|
|
|
|
if (get_filter_li(type, name).length) {
|
|
|
|
// already exists
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return build_narrow_filter(name, type);
|
|
|
|
}
|
|
|
|
|
2013-05-06 02:54:15 +02:00
|
|
|
exports.get_count = function (type, name) {
|
2013-05-06 22:18:01 +02:00
|
|
|
return get_filter_li(type, name).find('.count .value').text();
|
2013-05-06 02:54:15 +02:00
|
|
|
};
|
|
|
|
|
2013-05-16 22:38:09 +02:00
|
|
|
function update_count_in_dom(count_span, value_span, count) {
|
2013-05-07 20:02:24 +02:00
|
|
|
if (count === 0) {
|
2013-05-16 22:38:09 +02:00
|
|
|
count_span.hide();
|
2013-09-06 07:39:40 +02:00
|
|
|
if (count_span.parent().hasClass("subscription_block")) {
|
|
|
|
count_span.parent(".subscription_block").removeClass("stream-with-count");
|
|
|
|
}
|
|
|
|
else if (count_span.parent().hasClass("user_sidebar_entry")) {
|
|
|
|
count_span.parent(".user_sidebar_entry").removeClass("user-with-count");
|
|
|
|
}
|
2013-05-16 22:38:09 +02:00
|
|
|
value_span.text('');
|
|
|
|
return;
|
2013-05-07 20:02:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
count_span.show();
|
2013-09-06 07:39:40 +02:00
|
|
|
|
|
|
|
if (count_span.parent().hasClass("subscription_block")) {
|
|
|
|
count_span.parent(".subscription_block").addClass("stream-with-count");
|
|
|
|
}
|
|
|
|
else if (count_span.parent().hasClass("user_sidebar_entry")) {
|
|
|
|
count_span.parent(".user_sidebar_entry").addClass("user-with-count");
|
|
|
|
}
|
2013-05-07 20:02:24 +02:00
|
|
|
value_span.text(count);
|
|
|
|
}
|
|
|
|
|
2013-08-22 21:05:18 +02:00
|
|
|
function set_count(type, name, count) {
|
2013-05-06 22:18:01 +02:00
|
|
|
var count_span = get_filter_li(type, name).find('.count');
|
2013-05-06 02:54:15 +02:00
|
|
|
var value_span = count_span.find('.value');
|
2013-05-16 22:38:09 +02:00
|
|
|
update_count_in_dom(count_span, value_span, count);
|
2013-08-22 21:05:18 +02:00
|
|
|
}
|
2013-05-07 20:02:24 +02:00
|
|
|
|
2013-09-03 17:40:34 +02:00
|
|
|
function set_count_toggle_button(elem, count) {
|
|
|
|
if (count === 0) {
|
|
|
|
if (elem.is(':animated')) {
|
|
|
|
return elem.stop(true, true).hide();
|
|
|
|
}
|
|
|
|
return elem.hide(500);
|
|
|
|
} else if ((count > 0) && (count < 1000)) {
|
|
|
|
elem.show(500);
|
|
|
|
return elem.text(count);
|
|
|
|
} else {
|
|
|
|
elem.show(500);
|
|
|
|
return elem.text("1k+");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-07 20:02:24 +02:00
|
|
|
exports.set_subject_count = function (stream, subject, count) {
|
2013-06-07 16:56:05 +02:00
|
|
|
var subject_li = get_subject_filter_li(stream, subject);
|
|
|
|
var count_span = subject_li.find('.subject_count');
|
2013-05-07 20:02:24 +02:00
|
|
|
var value_span = count_span.find('.value');
|
|
|
|
|
|
|
|
if (count_span.length === 0 || value_span.length === 0) {
|
|
|
|
return;
|
2013-05-06 02:54:15 +02:00
|
|
|
}
|
|
|
|
|
2013-06-07 02:46:01 +02:00
|
|
|
count_span.removeClass("zero_count");
|
2013-05-16 22:38:09 +02:00
|
|
|
update_count_in_dom(count_span, value_span, count);
|
2013-05-06 02:54:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
exports.remove_narrow_filter = function (name, type) {
|
2013-05-06 22:18:01 +02:00
|
|
|
get_filter_li(type, name).remove();
|
2013-05-06 02:54:15 +02:00
|
|
|
};
|
|
|
|
|
2013-09-18 17:30:26 +02:00
|
|
|
function remove_expanded_subjects() {
|
|
|
|
popovers.hide_topic_sidebar_popover();
|
|
|
|
$("ul.expanded_subjects").remove();
|
|
|
|
}
|
|
|
|
|
2013-09-30 17:41:08 +02:00
|
|
|
function rebuild_recent_subjects(stream, active_topic) {
|
2013-06-07 22:33:33 +02:00
|
|
|
// TODO: Call rebuild_recent_subjects less, not on every new
|
|
|
|
// message.
|
2013-09-18 17:30:26 +02:00
|
|
|
remove_expanded_subjects();
|
2013-07-09 23:38:12 +02:00
|
|
|
var max_subjects = 5;
|
2013-05-06 22:18:01 +02:00
|
|
|
var stream_li = get_filter_li('stream', stream);
|
2013-08-07 23:56:51 +02:00
|
|
|
var subjects = recent_subjects.get(stream) || [];
|
2013-05-22 18:06:40 +02:00
|
|
|
|
2013-09-30 19:14:56 +02:00
|
|
|
if (active_topic) {
|
|
|
|
active_topic = active_topic.toLowerCase();
|
|
|
|
}
|
|
|
|
|
2013-09-30 17:27:32 +02:00
|
|
|
var display_subjects = [];
|
|
|
|
|
|
|
|
_.each(subjects, function (subject_obj, idx) {
|
2013-09-30 19:03:30 +02:00
|
|
|
var topic_name = subject_obj.subject;
|
2013-09-30 17:27:32 +02:00
|
|
|
var num_unread = unread.num_unread_for_subject(stream, subject_obj.canon_subject);
|
2013-05-06 02:54:15 +02:00
|
|
|
|
2013-06-27 16:26:33 +02:00
|
|
|
// Show the most recent subjects, as well as any with unread messages
|
2013-09-30 19:14:56 +02:00
|
|
|
if ((idx < max_subjects) || (num_unread > 0) || (active_topic === topic_name)) {
|
2013-09-30 17:27:32 +02:00
|
|
|
var display_subject = {
|
2013-09-30 19:03:30 +02:00
|
|
|
topic_name: topic_name,
|
2013-09-30 17:27:32 +02:00
|
|
|
unread: num_unread,
|
|
|
|
is_zero: num_unread === 0,
|
2013-09-30 22:03:10 +02:00
|
|
|
is_muted: muting.is_topic_muted(stream, topic_name),
|
2013-09-30 19:03:30 +02:00
|
|
|
url: narrow.by_stream_subject_uri(stream, topic_name)
|
2013-09-30 17:27:32 +02:00
|
|
|
};
|
|
|
|
display_subjects.push(display_subject);
|
|
|
|
}
|
2013-06-27 16:26:33 +02:00
|
|
|
});
|
2013-05-17 21:32:26 +02:00
|
|
|
|
2013-05-06 02:54:15 +02:00
|
|
|
stream_li.append(templates.render('sidebar_subject_list',
|
2013-06-27 16:26:33 +02:00
|
|
|
{subjects: display_subjects,
|
2013-05-06 02:54:15 +02:00
|
|
|
stream: stream}));
|
2013-06-07 02:46:01 +02:00
|
|
|
|
2013-09-30 17:41:08 +02:00
|
|
|
if (active_topic) {
|
|
|
|
get_subject_filter_li(stream, active_topic).addClass('active-subject-filter');
|
2013-05-06 02:54:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.update_streams_sidebar = function () {
|
|
|
|
exports.sort_narrow_list();
|
|
|
|
|
|
|
|
if (! narrow.active()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var op_stream = narrow.filter().operands('stream');
|
2013-07-16 22:52:02 +02:00
|
|
|
var op_subject = narrow.filter().operands('topic');
|
2013-05-06 02:54:15 +02:00
|
|
|
var subject;
|
|
|
|
if (op_stream.length !== 0) {
|
|
|
|
if (op_subject.length !== 0) {
|
|
|
|
subject = op_subject[0];
|
|
|
|
}
|
2013-08-15 21:11:07 +02:00
|
|
|
if (stream_data.is_subscribed(op_stream[0])) {
|
2013-05-06 02:54:15 +02:00
|
|
|
rebuild_recent_subjects(op_stream[0], subject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-05-31 19:07:59 +02:00
|
|
|
function do_new_messages_animation(message_type) {
|
|
|
|
var li = get_filter_li("global", message_type);
|
|
|
|
li.addClass("new_messages");
|
2013-05-16 23:40:07 +02:00
|
|
|
function mid_animation() {
|
2013-05-31 19:07:59 +02:00
|
|
|
li.removeClass("new_messages");
|
|
|
|
li.addClass("new_messages_fadeout");
|
2013-05-16 23:40:07 +02:00
|
|
|
}
|
|
|
|
function end_animation() {
|
2013-05-31 19:07:59 +02:00
|
|
|
li.removeClass("new_messages_fadeout");
|
2013-05-16 23:40:07 +02:00
|
|
|
}
|
|
|
|
setTimeout(mid_animation, 3000);
|
|
|
|
setTimeout(end_animation, 6000);
|
|
|
|
}
|
|
|
|
|
|
|
|
function animate_private_message_changes(new_private_message_count) {
|
|
|
|
if (new_private_message_count > last_private_message_count) {
|
2013-07-10 03:22:34 +02:00
|
|
|
do_new_messages_animation('private');
|
2013-05-16 23:40:07 +02:00
|
|
|
}
|
|
|
|
last_private_message_count = new_private_message_count;
|
|
|
|
}
|
|
|
|
|
2013-05-31 19:07:59 +02:00
|
|
|
function animate_mention_changes(new_mention_count) {
|
|
|
|
if (new_mention_count > last_mention_count) {
|
2013-07-10 03:07:01 +02:00
|
|
|
do_new_messages_animation('mentioned');
|
2013-05-31 19:07:59 +02:00
|
|
|
}
|
|
|
|
last_mention_count = new_mention_count;
|
|
|
|
}
|
|
|
|
|
2013-08-22 19:06:04 +02:00
|
|
|
|
2013-08-22 21:28:34 +02:00
|
|
|
exports.set_presence_list_count = function (person, count) {
|
|
|
|
set_count("private", person, count);
|
2013-08-22 19:06:04 +02:00
|
|
|
};
|
|
|
|
|
2013-05-14 03:58:07 +02:00
|
|
|
exports.update_dom_with_unread_counts = function (counts) {
|
|
|
|
// counts is just a data object that gets calculated elsewhere
|
|
|
|
// Our job is to update some DOM elements.
|
|
|
|
|
|
|
|
// counts.stream_count maps streams to counts
|
2013-08-15 16:16:12 +02:00
|
|
|
counts.stream_count.each(function (count, stream) {
|
2013-08-22 21:05:18 +02:00
|
|
|
set_count("stream", stream, count);
|
2013-05-14 03:58:07 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// counts.subject_count maps streams to hashes of subjects to counts
|
2013-08-15 16:16:12 +02:00
|
|
|
counts.subject_count.each(function (subject_hash, stream) {
|
|
|
|
subject_hash.each(function (count, subject) {
|
2013-05-14 03:58:07 +02:00
|
|
|
exports.set_subject_count(stream, subject, count);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-08-22 21:28:34 +02:00
|
|
|
|
|
|
|
counts.pm_count.each(function (count, person) {
|
|
|
|
exports.set_presence_list_count(person, count);
|
|
|
|
});
|
2013-06-05 20:29:31 +02:00
|
|
|
|
2013-05-14 03:58:07 +02:00
|
|
|
// integer counts
|
2013-08-22 21:05:18 +02:00
|
|
|
set_count("global", "private", counts.private_message_count);
|
|
|
|
set_count("global", "mentioned", counts.mentioned_message_count);
|
|
|
|
set_count("global", "home", counts.home_unread_messages);
|
2013-05-16 23:40:07 +02:00
|
|
|
|
2013-09-03 17:40:34 +02:00
|
|
|
set_count_toggle_button($("#streamlist-toggle-unreadcount"), counts.home_unread_messages);
|
|
|
|
set_count_toggle_button($("#userlist-toggle-unreadcount"), counts.private_message_count);
|
|
|
|
|
2013-05-16 23:40:07 +02:00
|
|
|
animate_private_message_changes(counts.private_message_count);
|
2013-05-31 19:07:59 +02:00
|
|
|
animate_mention_changes(counts.mentioned_message_count);
|
2013-05-14 03:58:07 +02:00
|
|
|
};
|
|
|
|
|
2013-10-21 22:26:19 +02:00
|
|
|
exports.rename_stream = function (sub) {
|
|
|
|
sub.sidebar_li = build_narrow_filter(sub.name, "stream");
|
|
|
|
exports.sort_narrow_list(); // big hammer
|
|
|
|
};
|
|
|
|
|
2013-05-06 02:54:15 +02:00
|
|
|
$(function () {
|
2013-07-25 22:48:55 +02:00
|
|
|
$(document).on('narrow_activated.zulip', function (event) {
|
2013-05-06 02:54:15 +02:00
|
|
|
$("ul.filters li").removeClass('active-filter active-subject-filter');
|
2013-09-18 17:30:26 +02:00
|
|
|
remove_expanded_subjects();
|
2013-05-06 02:54:15 +02:00
|
|
|
|
|
|
|
// TODO: handle confused filters like "in:all stream:foo"
|
|
|
|
var op_in = event.filter.operands('in');
|
|
|
|
if (op_in.length !== 0) {
|
|
|
|
if (['all', 'home'].indexOf(op_in[0]) !== -1) {
|
|
|
|
$("#global_filters li[data-name='" + op_in[0] + "']").addClass('active-filter');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var op_is = event.filter.operands('is');
|
|
|
|
if (op_is.length !== 0) {
|
2013-07-10 03:22:34 +02:00
|
|
|
if (['private', 'starred', 'mentioned'].indexOf(op_is[0]) !== -1) {
|
2013-05-06 02:54:15 +02:00
|
|
|
$("#global_filters li[data-name='" + op_is[0] + "']").addClass('active-filter');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var op_stream = event.filter.operands('stream');
|
2013-08-15 21:11:07 +02:00
|
|
|
if (op_stream.length !== 0 && stream_data.is_subscribed(op_stream[0])) {
|
2013-05-06 22:18:01 +02:00
|
|
|
var stream_li = get_filter_li('stream', op_stream[0]);
|
2013-07-16 22:52:02 +02:00
|
|
|
var op_subject = event.filter.operands('topic');
|
2013-05-06 02:54:15 +02:00
|
|
|
var subject;
|
|
|
|
if (op_subject.length !== 0) {
|
|
|
|
subject = op_subject[0];
|
|
|
|
} else {
|
|
|
|
stream_li.addClass('active-filter');
|
|
|
|
}
|
|
|
|
rebuild_recent_subjects(op_stream[0], subject);
|
2013-07-11 17:14:11 +02:00
|
|
|
process_visible_unread_messages();
|
2013-05-06 02:54:15 +02:00
|
|
|
}
|
2013-08-12 23:05:20 +02:00
|
|
|
var op_pm = event.filter.operands('pm-with');
|
|
|
|
if (op_pm.length === 1) {
|
|
|
|
$("#user_presences li[data-email='" + op_pm[0] + "']").addClass('active-filter');
|
|
|
|
}
|
2013-05-06 02:54:15 +02:00
|
|
|
});
|
|
|
|
|
2013-07-25 22:48:55 +02:00
|
|
|
$(document).on('narrow_deactivated.zulip', function (event) {
|
2013-05-06 02:54:15 +02:00
|
|
|
$("ul.filters li").removeClass('active-filter active-subject-filter');
|
2013-09-18 17:30:26 +02:00
|
|
|
remove_expanded_subjects();
|
2013-05-06 02:54:15 +02:00
|
|
|
$("#global_filters li[data-name='home']").addClass('active-filter');
|
|
|
|
});
|
2013-05-06 02:54:15 +02:00
|
|
|
|
2013-07-25 22:48:55 +02:00
|
|
|
$(document).on('sub_obj_created.zulip', function (event) {
|
2013-05-06 02:54:15 +02:00
|
|
|
if (event.sub.subscribed) {
|
|
|
|
var stream_name = event.sub.name;
|
2013-05-06 23:36:22 +02:00
|
|
|
var li = add_narrow_filter(stream_name, "stream");
|
|
|
|
if (li) {
|
|
|
|
event.sub.sidebar_li = li;
|
|
|
|
}
|
2013-05-06 02:54:15 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2013-07-25 22:48:55 +02:00
|
|
|
$(document).on('subscription_add_done.zulip', function (event) {
|
2013-05-06 02:54:15 +02:00
|
|
|
var stream_name = event.sub.name;
|
2013-05-06 23:36:22 +02:00
|
|
|
var li = add_narrow_filter(stream_name, "stream");
|
|
|
|
if (li) {
|
|
|
|
event.sub.sidebar_li = li;
|
|
|
|
}
|
2013-05-06 02:54:15 +02:00
|
|
|
exports.sort_narrow_list();
|
|
|
|
});
|
|
|
|
|
2013-07-25 22:48:55 +02:00
|
|
|
$(document).on('subscription_remove_done.zulip', function (event) {
|
2013-05-06 02:54:15 +02:00
|
|
|
var stream_name = event.sub.name;
|
|
|
|
exports.remove_narrow_filter(stream_name, 'stream');
|
2013-05-13 17:23:07 +02:00
|
|
|
// We need to make sure we resort if the removed sub gets added again
|
|
|
|
previous_sort_order = undefined;
|
2013-05-06 02:54:15 +02:00
|
|
|
});
|
2013-05-06 02:54:15 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
return exports;
|
|
|
|
}());
|