mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
subscription: Clean functions peer_subscribe and peer_unsubscribe.
This commit is contained in:
@@ -246,9 +246,6 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'subscription':
|
case 'subscription':
|
||||||
var person;
|
|
||||||
var email;
|
|
||||||
|
|
||||||
if (event.op === 'add') {
|
if (event.op === 'add') {
|
||||||
_.each(event.subscriptions, function (rec) {
|
_.each(event.subscriptions, function (rec) {
|
||||||
var sub = stream_data.get_sub_by_id(rec.stream_id);
|
var sub = stream_data.get_sub_by_id(rec.stream_id);
|
||||||
@@ -260,29 +257,17 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (event.op === 'peer_add') {
|
} else if (event.op === 'peer_add') {
|
||||||
// TODO: remove email shim here and fix called functions
|
|
||||||
// to use user_ids
|
|
||||||
person = people.get_person_from_user_id(event.user_id);
|
|
||||||
email = person.email;
|
|
||||||
_.each(event.subscriptions, function (sub) {
|
_.each(event.subscriptions, function (sub) {
|
||||||
if (stream_data.add_subscriber(sub, event.user_id)) {
|
if (stream_data.add_subscriber(sub, event.user_id)) {
|
||||||
$(document).trigger(
|
$(document).trigger('peer_subscribe.zulip', {stream_name: sub});
|
||||||
'peer_subscribe.zulip',
|
|
||||||
{stream_name: sub, user_email: email});
|
|
||||||
} else {
|
} else {
|
||||||
blueslip.warn('Cannot process peer_add event');
|
blueslip.warn('Cannot process peer_add event');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (event.op === 'peer_remove') {
|
} else if (event.op === 'peer_remove') {
|
||||||
// TODO: remove email shim here and fix called functions
|
|
||||||
// to use user_ids
|
|
||||||
person = people.get_person_from_user_id(event.user_id);
|
|
||||||
email = person.email;
|
|
||||||
_.each(event.subscriptions, function (sub) {
|
_.each(event.subscriptions, function (sub) {
|
||||||
if (stream_data.remove_subscriber(sub, event.user_id)) {
|
if (stream_data.remove_subscriber(sub, event.user_id)) {
|
||||||
$(document).trigger(
|
$(document).trigger('peer_unsubscribe.zulip', {stream_name: sub});
|
||||||
'peer_unsubscribe.zulip',
|
|
||||||
{stream_name: sub, user_email: email});
|
|
||||||
} else {
|
} else {
|
||||||
blueslip.warn('Cannot process peer_remove event.');
|
blueslip.warn('Cannot process peer_remove event.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -632,12 +632,12 @@ $(function () {
|
|||||||
|
|
||||||
$(document).on('peer_subscribe.zulip', function (e, data) {
|
$(document).on('peer_subscribe.zulip', function (e, data) {
|
||||||
var sub = stream_data.get_sub(data.stream_name);
|
var sub = stream_data.get_sub(data.stream_name);
|
||||||
exports.rerender_subscribers_list(sub);
|
subs.rerender_subscriptions_settings(sub);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('peer_unsubscribe.zulip', function (e, data) {
|
$(document).on('peer_unsubscribe.zulip', function (e, data) {
|
||||||
var sub = stream_data.get_sub(data.stream_name);
|
var sub = stream_data.get_sub(data.stream_name);
|
||||||
exports.rerender_subscribers_list(sub);
|
subs.rerender_subscriptions_settings(sub);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -814,17 +814,6 @@ $(function () {
|
|||||||
sub_arrow.removeClass('icon-vector-chevron-up');
|
sub_arrow.removeClass('icon-vector-chevron-up');
|
||||||
sub_arrow.addClass('icon-vector-chevron-down');
|
sub_arrow.addClass('icon-vector-chevron-down');
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('peer_subscribe.zulip', function (e, data) {
|
|
||||||
var sub = stream_data.get_sub(data.stream_name);
|
|
||||||
exports.rerender_subscribers_count(sub);
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).on('peer_unsubscribe.zulip', function (e, data) {
|
|
||||||
var sub = stream_data.get_sub(data.stream_name);
|
|
||||||
exports.rerender_subscribers_count(sub);
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function focus_on_narrowed_stream() {
|
function focus_on_narrowed_stream() {
|
||||||
|
|||||||
Reference in New Issue
Block a user