Make newly subscribed streams appear active.

When you subscribe to a stream, we now set a newly_subscribed
flag on the object, and we return true during the is_active()
call.

This solves the problem that immediately after you subscribe, you
don't have any messages in the stream, so it would appear active
by our old criteria.

This is still something of a workaround, as once you reload, the
stream will become inactive again, unless other messages come in.

A more permanent solution here would be to have the backend
indicate newly subscribed streams to us (apart from the initial
event), but we may not really need that in practice.
This commit is contained in:
Steve Howell
2017-04-28 06:59:30 -07:00
parent f9b3ff8f68
commit 0ced7cfc55
2 changed files with 33 additions and 1 deletions

View File

@@ -298,6 +298,35 @@ var people = global.people;
]);
}());
(function test_is_active() {
stream_data.clear_subscriptions();
var sub = {name: 'pets', subscribed: false, stream_id: 1};
stream_data.add_sub('pets', sub);
assert(!stream_data.is_active(sub));
stream_data.subscribe_myself(sub);
assert(stream_data.is_active(sub));
stream_data.unsubscribe_myself(sub);
assert(!stream_data.is_active(sub));
sub = {name: 'lunch', subscribed: false, stream_id: 1};
stream_data.add_sub('lunch', sub);
assert(!stream_data.is_active(sub));
var message = {
stream: 'lunch',
timestamp: 108,
subject: 'topic2',
};
stream_data.process_message_for_recent_topics(message);
assert(stream_data.is_active(sub));
}());
(function test_admin_options() {
function make_sub() {
return {