Have "n" key skip muted topics.

This commit is contained in:
Steve Howell
2017-05-17 07:33:41 -07:00
committed by Tim Abbott
parent d827cc878b
commit 6f73b7953f
2 changed files with 16 additions and 7 deletions

View File

@@ -1,4 +1,5 @@
add_dependencies({ add_dependencies({
muting: 'js/muting',
stream_data: 'js/stream_data', stream_data: 'js/stream_data',
stream_sort: 'js/stream_sort', stream_sort: 'js/stream_sort',
unread: 'js/unread', unread: 'js/unread',
@@ -163,7 +164,7 @@ function is_odd(i) { return i % 2 === 1; }
global.stream_data.get_recent_topics = function (stream) { global.stream_data.get_recent_topics = function (stream) {
if (stream === 'devel') { if (stream === 'devel') {
return [ return [
{subject: 'javascript'}, {subject: 'muted'},
{subject: 'python'}, {subject: 'python'},
]; ];
} }
@@ -179,8 +180,12 @@ function is_odd(i) { return i % 2 === 1; }
return 999; return 999;
}; };
global.unread.topic_has_any_unread = function (stream_id, topic) { global.unread.topic_has_any_unread = function (stream_id) {
return (stream_id === devel_stream_id && topic === 'python'); return (stream_id === devel_stream_id);
};
global.muting.is_topic_muted = function (stream_name, topic) {
return (topic === 'muted');
}; };
var next_item = tg.get_next_topic(curr_stream, curr_topic); var next_item = tg.get_next_topic(curr_stream, curr_topic);

View File

@@ -158,9 +158,13 @@ exports.next_topic = function (streams, get_topics, has_unread_messages, curr_st
exports.get_next_topic = function (curr_stream, curr_topic) { exports.get_next_topic = function (curr_stream, curr_topic) {
var my_streams = stream_sort.get_streams(); var my_streams = stream_sort.get_streams();
function get_topics(stream) { function get_unmuted_topics(stream_name) {
var topics = stream_data.get_recent_topics(stream) || []; var topic_objs = stream_data.get_recent_topics(stream_name) || [];
return _.map(topics, function (obj) { return obj.subject; }); var topics = _.map(topic_objs, function (obj) { return obj.subject; });
topics = _.reject(topics, function (topic) {
return muting.is_topic_muted(stream_name, topic);
});
return topics;
} }
function has_unread_messages(stream_name, topic) { function has_unread_messages(stream_name, topic) {
@@ -170,7 +174,7 @@ exports.get_next_topic = function (curr_stream, curr_topic) {
return exports.next_topic( return exports.next_topic(
my_streams, my_streams,
get_topics, get_unmuted_topics,
has_unread_messages, has_unread_messages,
curr_stream, curr_stream,
curr_topic curr_topic