From 78f2df56492d076d644f1fbbabb777e13a97c5bd Mon Sep 17 00:00:00 2001 From: fionabunny Date: Mon, 24 Apr 2017 12:33:48 -0700 Subject: [PATCH] home.py: move initial_pointer as pointer to register_ret. This is the last of the fields in page_params that could come from register_ret but wasn't doing so. --- static/js/message_fetch.js | 6 +++--- static/js/narrow.js | 4 ++-- static/js/pointer.js | 2 +- static/js/reload.js | 4 ++-- zerver/tests/test_home.py | 4 ++-- zerver/views/home.py | 7 ++----- 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/static/js/message_fetch.js b/static/js/message_fetch.js index 2ac22bffbe..833edc1996 100644 --- a/static/js/message_fetch.js +++ b/static/js/message_fetch.js @@ -138,7 +138,7 @@ exports.load_more_messages = function load_more_messages(msg_list) { ui.show_loading_more_messages_indicator(); load_more_enabled = false; if (msg_list.first() === undefined) { - oldest_message_id = page_params.initial_pointer; + oldest_message_id = page_params.pointer; } else { oldest_message_id = msg_list.first().id; } @@ -166,7 +166,7 @@ util.execute_early(function () { // We fall back to the closest selected id, as the user may have removed // a stream from the home before already if (home_msg_list.selected_id() === -1 && !home_msg_list.empty()) { - home_msg_list.select_id(page_params.initial_pointer, + home_msg_list.select_id(page_params.pointer, {then_scroll: true, use_closest: true, target_scroll_offset: page_params.initial_offset}); } @@ -204,7 +204,7 @@ util.execute_early(function () { if (page_params.have_initial_messages) { exports.load_old_messages({ - anchor: page_params.initial_pointer, + anchor: page_params.pointer, num_before: 200, num_after: 200, msg_list: home_msg_list, diff --git a/static/js/narrow.js b/static/js/narrow.js index 3615c1d3fe..a389f71b68 100644 --- a/static/js/narrow.js +++ b/static/js/narrow.js @@ -99,8 +99,8 @@ exports.activate = function (raw_operators, opts) { if (opts.then_select_id === -1 && !opts.first_unread_from_server) { // According to old comments, this shouldn't happen anymore - blueslip.warn("Setting then_select_id to page_params.initial_pointer."); - opts.then_select_id = page_params.initial_pointer; + blueslip.warn("Setting then_select_id to page_params.pointer."); + opts.then_select_id = page_params.pointer; opts.select_first_unread = false; } diff --git a/static/js/pointer.js b/static/js/pointer.js index 0be22740da..d870a95efc 100644 --- a/static/js/pointer.js +++ b/static/js/pointer.js @@ -75,7 +75,7 @@ exports.fast_forward_pointer = function () { }; exports.initialize = function initialize() { - pointer.server_furthest_read = page_params.initial_pointer; + pointer.server_furthest_read = page_params.pointer; if (page_params.orig_initial_pointer !== undefined && page_params.orig_initial_pointer > pointer.server_furthest_read) { pointer.server_furthest_read = page_params.orig_initial_pointer; diff --git a/static/js/reload.js b/static/js/reload.js index a9f45960f2..602c18085b 100644 --- a/static/js/reload.js +++ b/static/js/reload.js @@ -135,8 +135,8 @@ exports.initialize = function reload__initialize() { var pointer = parseInt(vars.pointer, 10); if (pointer) { - page_params.orig_initial_pointer = page_params.initial_pointer; - page_params.initial_pointer = pointer; + page_params.orig_initial_pointer = page_params.pointer; + page_params.pointer = pointer; } var offset = parseInt(vars.offset, 10); if (offset) { diff --git a/zerver/tests/test_home.py b/zerver/tests/test_home.py index f754b85227..8c1a6f3a9b 100644 --- a/zerver/tests/test_home.py +++ b/zerver/tests/test_home.py @@ -72,7 +72,6 @@ class HomeTest(ZulipTestCase): "has_mobile_devices", "have_initial_messages", "hotspots", - "initial_pointer", "initial_servertime", "is_admin", "language_list", @@ -91,6 +90,7 @@ class HomeTest(ZulipTestCase): "never_subscribed", "notifications_stream", "pm_content_in_desktop_notifications", + "pointer", "poll_timeout", "presences", "prompt_for_invites", @@ -353,7 +353,7 @@ class HomeTest(ZulipTestCase): page_params = self._get_page_params(result) self.assertEqual(page_params['narrow_stream'], stream_name) self.assertEqual(page_params['narrow'], [dict(operator='stream', operand=stream_name)]) - self.assertEqual(page_params['initial_pointer'], -1) + self.assertEqual(page_params['pointer'], -1) self.assertEqual(page_params['max_message_id'], -1) self.assertEqual(page_params['have_initial_messages'], False) diff --git a/zerver/views/home.py b/zerver/views/home.py index 99d60a202e..c62de69a54 100644 --- a/zerver/views/home.py +++ b/zerver/views/home.py @@ -204,10 +204,6 @@ def home_real(request): server_inline_image_preview = settings.INLINE_IMAGE_PREVIEW, server_inline_url_embed_preview = settings.INLINE_URL_EMBED_PREVIEW, - # Realm foreign key data from register_ret. - # TODO: Rename these to match register_ret values. - initial_pointer = register_ret['pointer'], - # Misc. extra data. have_initial_messages = user_has_messages, initial_servertime = time.time(), # Used for calculating relative presence age @@ -260,6 +256,7 @@ def home_real(request): 'muted_topics', 'never_subscribed', 'pm_content_in_desktop_notifications', + 'pointer', 'presences', 'queue_id', 'realm_add_emoji_by_admins_only', @@ -318,7 +315,7 @@ def home_real(request): page_params["narrow_topic"] = narrow_topic page_params["narrow"] = [dict(operator=term[0], operand=term[1]) for term in narrow] page_params["max_message_id"] = initial_pointer - page_params["initial_pointer"] = initial_pointer + page_params["pointer"] = initial_pointer page_params["have_initial_messages"] = (initial_pointer != -1) page_params["enable_desktop_notifications"] = False