mirror of
https://github.com/zulip/zulip.git
synced 2025-11-15 19:31:58 +00:00
unread: Move consider_bankruptcy into unread module.
This commit is contained in:
@@ -562,6 +562,7 @@ $(function () {
|
|||||||
gear_menu.initialize();
|
gear_menu.initialize();
|
||||||
hashchange.initialize();
|
hashchange.initialize();
|
||||||
invite.initialize();
|
invite.initialize();
|
||||||
|
unread.initialize();
|
||||||
activity.initialize();
|
activity.initialize();
|
||||||
emoji.initialize();
|
emoji.initialize();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -301,6 +301,35 @@ exports.mark_topic_as_read = function mark_topic_as_read(stream, topic, cont) {
|
|||||||
success: cont});
|
success: cont});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function consider_bankruptcy() {
|
||||||
|
// Until we've handled possibly declaring bankruptcy, don't show
|
||||||
|
// unread counts since they only consider messages that are loaded
|
||||||
|
// client side and may be different from the numbers reported by
|
||||||
|
// the server.
|
||||||
|
|
||||||
|
if (!page_params.furthest_read_time) {
|
||||||
|
// We've never read a message.
|
||||||
|
unread.enable();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var now = new XDate(true).getTime() / 1000;
|
||||||
|
if ((page_params.unread_count > 500) &&
|
||||||
|
(now - page_params.furthest_read_time > 60 * 60 * 24 * 2)) { // 2 days.
|
||||||
|
var unread_info = templates.render('bankruptcy_modal',
|
||||||
|
{"unread_count": page_params.unread_count});
|
||||||
|
$('#bankruptcy-unread-count').html(unread_info);
|
||||||
|
$('#bankruptcy').modal('show');
|
||||||
|
} else {
|
||||||
|
unread.enable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exports.initialize = function initialize() {
|
||||||
|
consider_bankruptcy();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
return exports;
|
return exports;
|
||||||
}());
|
}());
|
||||||
if (typeof module !== 'undefined') {
|
if (typeof module !== 'undefined') {
|
||||||
|
|||||||
@@ -7,30 +7,6 @@ var home_msg_list = new message_list.MessageList('zhome',
|
|||||||
);
|
);
|
||||||
var current_msg_list = home_msg_list;
|
var current_msg_list = home_msg_list;
|
||||||
|
|
||||||
function consider_bankruptcy() {
|
|
||||||
// Until we've handled possibly declaring bankruptcy, don't show
|
|
||||||
// unread counts since they only consider messages that are loaded
|
|
||||||
// client side and may be different from the numbers reported by
|
|
||||||
// the server.
|
|
||||||
|
|
||||||
if (!page_params.furthest_read_time) {
|
|
||||||
// We've never read a message.
|
|
||||||
unread.enable();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var now = new XDate(true).getTime() / 1000;
|
|
||||||
if ((page_params.unread_count > 500) &&
|
|
||||||
(now - page_params.furthest_read_time > 60 * 60 * 24 * 2)) { // 2 days.
|
|
||||||
var unread_info = templates.render('bankruptcy_modal',
|
|
||||||
{"unread_count": page_params.unread_count});
|
|
||||||
$('#bankruptcy-unread-count').html(unread_info);
|
|
||||||
$('#bankruptcy').modal('show');
|
|
||||||
} else {
|
|
||||||
unread.enable();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is annoying to move to unread.js because the natural name
|
// This is annoying to move to unread.js because the natural name
|
||||||
// would be unread.process_loaded_messages, which this calls
|
// would be unread.process_loaded_messages, which this calls
|
||||||
function process_loaded_for_unread(messages) {
|
function process_loaded_for_unread(messages) {
|
||||||
@@ -52,9 +28,6 @@ function main() {
|
|||||||
}
|
}
|
||||||
pointer.furthest_read = pointer.server_furthest_read;
|
pointer.furthest_read = pointer.server_furthest_read;
|
||||||
|
|
||||||
// Before trying to load messages: is this user way behind?
|
|
||||||
consider_bankruptcy();
|
|
||||||
|
|
||||||
// We only send pointer updates when the user has been idle for a
|
// We only send pointer updates when the user has been idle for a
|
||||||
// short while to avoid hammering the server
|
// short while to avoid hammering the server
|
||||||
$(document).idle({idle: 1000,
|
$(document).idle({idle: 1000,
|
||||||
|
|||||||
Reference in New Issue
Block a user