Don't display unread counts until after making a bankruptcy decision.

Users were getting confused about why the unread count in the sidebar
/ notification bar / Dock was different from what the bankruptcy modal
said, so only show them the true server count until they've made a
decision.

(imported from commit 71d376cd4a85749ccf49936b251e6b8ac21361b7)
This commit is contained in:
Jessica McKellar
2013-08-19 13:02:52 -04:00
parent 8010b49067
commit b32219c8eb
4 changed files with 27 additions and 3 deletions

View File

@@ -1382,6 +1382,10 @@ $(function () {
compose.cancel();
});
$(".bankruptcy_button").click(function (e) {
enable_unread_counts();
});
$('#yes-bankrupt').click(function (e) {
fast_forward_pointer();
$("#yes-bankrupt").hide();

View File

@@ -33,6 +33,7 @@ var last_viewport_movement_direction = 1;
var furthest_read = -1;
var server_furthest_read = -1;
var pointer_update_in_flight = false;
var suppress_unread_counts = true;
var events_stored_during_tutorial = [];
@@ -301,6 +302,10 @@ var send_summarize_in_stream = batched_flag_updater('summarize_in_stream', 'add'
var send_summarize_in_home = batched_flag_updater('summarize_in_home', 'add');
function update_unread_counts() {
if (suppress_unread_counts) {
return;
}
// Pure computation:
var res = unread.get_counts();
@@ -313,6 +318,11 @@ function update_unread_counts() {
notifications_bar.update(res.home_unread_messages);
}
function enable_unread_counts() {
suppress_unread_counts = false;
update_unread_counts();
}
function mark_all_as_read(cont) {
_.each(all_msg_list.all(), function (msg) {
msg.flags = msg.flags || [];
@@ -1164,8 +1174,14 @@ function fast_forward_pointer() {
}
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.
enable_unread_counts();
return;
}
@@ -1176,6 +1192,8 @@ function consider_bankruptcy() {
{"unread_count": page_params.unread_count});
$('#bankruptcy-unread-count').html(unread_info);
$('#bankruptcy').modal('show');
} else {
enable_unread_counts();
}
}

View File

@@ -9,7 +9,9 @@
<div id="bankruptcy-unread-count"></div>
<div class="modal-footer">
<button id="yes-bankrupt" class="btn btn-primary" aria-hidden="true">Yes, please!</button>
<button id="no-bankrupt" class="btn" data-dismiss="modal" aria-hidden="true">No, I'll catch up.</button>
<button id="yes-bankrupt" class="bankruptcy_button btn btn-primary"
aria-hidden="true">Yes, please!</button>
<button id="no-bankrupt" class="bankruptcy_button btn"
data-dismiss="modal" aria-hidden="true">No, I'll catch up.</button>
</div>
</div>

View File

@@ -44,7 +44,7 @@ var globals =
+ ' keep_pointer_in_view'
+ ' respond_to_message recenter_view last_viewport_movement_direction'
+ ' scroll_to_selected get_private_message_recipient'
+ ' load_old_messages'
+ ' load_old_messages enable_unread_counts'
+ ' at_top_of_viewport at_bottom_of_viewport within_viewport'
+ ' process_visible_unread_messages viewport restart_get_updates force_get_updates'
+ ' load_more_messages reset_load_more_status have_scrolled_away_from_top'