mirror of https://github.com/zulip/zulip.git
Allow negative anchor param to get_old_message
When narrowing, we use the selected id in the home view as the anchor, and if the user is new and hasn't selected any messages yet (or moved the pointer since first using humbug), their home view selected message will be -1. Rather than failing to get_old_messages for any narrows starting from that point, return all matching messages. (imported from commit 72cfe392d9ac01ed41abc8eadf0f47240e374665)
This commit is contained in:
parent
436d3b2578
commit
9466addbe2
|
@ -1005,13 +1005,13 @@ class GetOldMessagesTest(AuthedTestCase):
|
||||||
|
|
||||||
def test_bad_int_params(self):
|
def test_bad_int_params(self):
|
||||||
"""
|
"""
|
||||||
anchor, num_before, num_after, and narrow must all be non-negative
|
num_before, num_after, and narrow must all be non-negative
|
||||||
integers or strings that can be converted to non-negative integers.
|
integers or strings that can be converted to non-negative integers.
|
||||||
"""
|
"""
|
||||||
self.login("hamlet@humbughq.com")
|
self.login("hamlet@humbughq.com")
|
||||||
|
|
||||||
other_params = [("narrow", {})]
|
other_params = [("narrow", {}), ("anchor", 0)]
|
||||||
int_params = ["anchor", "num_before", "num_after"]
|
int_params = ["num_before", "num_after"]
|
||||||
|
|
||||||
bad_types = (False, "", "-1", -1)
|
bad_types = (False, "", "-1", -1)
|
||||||
for idx, param in enumerate(int_params):
|
for idx, param in enumerate(int_params):
|
||||||
|
|
|
@ -585,7 +585,7 @@ def get_public_stream(request, stream, realm):
|
||||||
return stream
|
return stream
|
||||||
|
|
||||||
@has_request_variables
|
@has_request_variables
|
||||||
def get_old_messages_backend(request, anchor = POST(converter=to_non_negative_int),
|
def get_old_messages_backend(request, anchor = POST(converter=int),
|
||||||
num_before = POST(converter=to_non_negative_int),
|
num_before = POST(converter=to_non_negative_int),
|
||||||
num_after = POST(converter=to_non_negative_int),
|
num_after = POST(converter=to_non_negative_int),
|
||||||
narrow = POST('narrow', converter=narrow_parameter, default=None),
|
narrow = POST('narrow', converter=narrow_parameter, default=None),
|
||||||
|
|
Loading…
Reference in New Issue