Import initial subscriber lists from page_params.stream_list

(imported from commit b9679d30e4235efb6f47c2fa6c006790df616564)
This commit is contained in:
Scott Feeney
2013-09-06 20:48:44 -04:00
parent 17cad06a2d
commit dfaca2e9c7
2 changed files with 29 additions and 1 deletions

View File

@@ -92,6 +92,33 @@ exports.get_name = function (stream_name) {
return sub.name; return sub.name;
}; };
exports.add_subscriber = function (stream_name, user_email) {
var sub = exports.get_sub(stream_name);
if (!sub.hasOwnProperty('subscribers')) {
// FIXME: Temporary hack because this is not initialized.
sub.subscribers = new Dict();
}
sub.subscribers.set(user_email, true);
};
exports.remove_subscriber = function (stream_name, user_email) {
var sub = exports.get_sub(stream_name);
if (!sub.hasOwnProperty('subscribers')) {
// FIXME: Temporary hack because this is not initialized.
return;
}
sub.subscribers.del(user_email);
};
exports.user_is_subscribed = function (stream_name, user_email) {
var sub = exports.get_sub(stream_name);
if (!sub.hasOwnProperty('subscribers')) {
// FIXME: Hack because this is not fully implemented.
return undefined;
}
return sub.subscribers.has(user_email);
};
return exports; return exports;
}()); }());

View File

@@ -334,7 +334,8 @@ function populate_subscriptions(subs, subscribed) {
var sub = create_sub(stream_name, {color: elem.color, in_home_view: elem.in_home_view, var sub = create_sub(stream_name, {color: elem.color, in_home_view: elem.in_home_view,
invite_only: elem.invite_only, invite_only: elem.invite_only,
notifications: elem.notifications, subscribed: subscribed, notifications: elem.notifications, subscribed: subscribed,
email_address: elem.email_address}); email_address: elem.email_address,
subscribers: Dict.from_array(elem.subscribers)});
sub_rows.push(sub); sub_rows.push(sub);
}); });