diff --git a/templates/zephyr/bankruptcy.html b/templates/zephyr/bankruptcy.html new file mode 100644 index 0000000000..e4312e3bd2 --- /dev/null +++ b/templates/zephyr/bankruptcy.html @@ -0,0 +1,15 @@ + diff --git a/templates/zephyr/index.html b/templates/zephyr/index.html index 1ad88088f7..ea22abba09 100644 --- a/templates/zephyr/index.html +++ b/templates/zephyr/index.html @@ -57,6 +57,7 @@ var page_params = {{ page_params }}; {% include "zephyr/keyboard_shortcuts.html" %} {% include "zephyr/markdown_help.html" %} {% include "zephyr/invite_user.html" %} + {% include "zephyr/bankruptcy.html" %} {% include "zephyr/logout.html" %} {% endblock %} diff --git a/zephyr/static/js/ui.js b/zephyr/static/js/ui.js index 35bd3785c6..dd2408c6b3 100644 --- a/zephyr/static/js/ui.js +++ b/zephyr/static/js/ui.js @@ -1576,6 +1576,10 @@ $(function () { compose.cancel(); }); + $('#yes-bankrupt').click(function (e) { + fast_forward_pointer(this); + }); + // initialize other stuff composebox_typeahead.initialize(); search.initialize(); diff --git a/zephyr/static/js/zephyr.js b/zephyr/static/js/zephyr.js index 30b5447937..753c1f54c7 100644 --- a/zephyr/static/js/zephyr.js +++ b/zephyr/static/js/zephyr.js @@ -1058,6 +1058,22 @@ function load_old_messages(opts) { // get the initial message list $(function () { function load_more(messages) { + + // Before trying to load anything: is this user way behind? + var last_read_message = home_msg_list.get(home_msg_list.closest_id(page_params.initial_pointer)); + if (last_read_message !== undefined) { + var now = new XDate().getTime() / 1000; + var num_unread = unread.get_counts().home_unread_messages; + + if ((num_unread > 500) && + (now - last_read_message.timestamp > 60 * 60 * 24 * 2)) { // 2 days. + var unread_info = templates.render('bankruptcy_modal', + {"unread_count": num_unread}); + $('#bankruptcy-unread-count').html(unread_info); + $('#bankruptcy').modal('show'); + } + } + // If we received the initially selected message, select it on the client side, // but not if the user has already selected another one during load. // diff --git a/zephyr/static/templates/bankruptcy_modal.handlebars b/zephyr/static/templates/bankruptcy_modal.handlebars new file mode 100644 index 0000000000..f19da2fbaa --- /dev/null +++ b/zephyr/static/templates/bankruptcy_modal.handlebars @@ -0,0 +1,6 @@ +{{! The unread count in the bankruptcy modal }} + +