diff --git a/static/js/ui.js b/static/js/ui.js index 09bd12ae02..9c8bd10969 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -562,6 +562,7 @@ $(function () { gear_menu.initialize(); hashchange.initialize(); invite.initialize(); + unread.initialize(); activity.initialize(); emoji.initialize(); }); diff --git a/static/js/unread.js b/static/js/unread.js index 7992b9fbe1..2f7885f473 100644 --- a/static/js/unread.js +++ b/static/js/unread.js @@ -301,6 +301,35 @@ exports.mark_topic_as_read = function mark_topic_as_read(stream, topic, 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; }()); if (typeof module !== 'undefined') { diff --git a/static/js/zulip.js b/static/js/zulip.js index 93c69b27bf..3c2947de5e 100644 --- a/static/js/zulip.js +++ b/static/js/zulip.js @@ -7,30 +7,6 @@ var home_msg_list = new message_list.MessageList('zhome', ); 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 // would be unread.process_loaded_messages, which this calls function process_loaded_for_unread(messages) { @@ -52,9 +28,6 @@ function main() { } 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 // short while to avoid hammering the server $(document).idle({idle: 1000,