Move receives_*_notifications() to stream_data.js.

This moves these functions from subs.js to stream_data.js:

    receives_desktop_notifications
    receives_audible_notifications

This makes notifications.js no longer dependent on the
bloated subs.js.
This commit is contained in:
Steve Howell
2016-10-17 06:53:06 -07:00
committed by Tim Abbott
parent e25b67af26
commit cf08f04dbc
3 changed files with 18 additions and 18 deletions

View File

@@ -400,7 +400,7 @@ function should_send_desktop_notification(message) {
// For streams, send if desktop notifications are enabled for this // For streams, send if desktop notifications are enabled for this
// stream. // stream.
if ((message.type === "stream") && if ((message.type === "stream") &&
subs.receives_desktop_notifications(message.stream)) { stream_data.receives_desktop_notifications(message.stream)) {
return true; return true;
} }
@@ -429,7 +429,7 @@ function should_send_desktop_notification(message) {
function should_send_audible_notification(message) { function should_send_audible_notification(message) {
// For streams, ding if sounds are enabled for this stream. // For streams, ding if sounds are enabled for this stream.
if ((message.type === "stream") && if ((message.type === "stream") &&
subs.receives_audible_notifications(message.stream)) { stream_data.receives_audible_notifications(message.stream)) {
return true; return true;
} }

View File

@@ -193,6 +193,22 @@ exports.create_sub_from_server_data = function (stream_name, attrs) {
return sub; return sub;
}; };
exports.receives_desktop_notifications = function (stream_name) {
var sub = exports.get_sub(stream_name);
if (sub === undefined) {
return false;
}
return sub.desktop_notifications;
};
exports.receives_audible_notifications = function (stream_name) {
var sub = exports.get_sub(stream_name);
if (sub === undefined) {
return false;
}
return sub.audible_notifications;
};
return exports; return exports;
}()); }());

View File

@@ -381,22 +381,6 @@ exports.pin_or_unpin_stream = function (stream_name) {
} }
}; };
exports.receives_desktop_notifications = function (stream_name) {
var sub = stream_data.get_sub(stream_name);
if (sub === undefined) {
return false;
}
return sub.desktop_notifications;
};
exports.receives_audible_notifications = function (stream_name) {
var sub = stream_data.get_sub(stream_name);
if (sub === undefined) {
return false;
}
return sub.audible_notifications;
};
function populate_subscriptions(subs, subscribed) { function populate_subscriptions(subs, subscribed) {
var sub_rows = []; var sub_rows = [];
subs.sort(function (a, b) { subs.sort(function (a, b) {