Skip to content

Commit

Permalink
model: Change next_unread_topic to return None if topic stays same.
Browse files Browse the repository at this point in the history
The next_unread_topic_from_message_id function returns the next topic
to be narrowed to. If the topic remains same, there is no need to call
narrow to the same topic again. This commit fixes this, without any
change in user-facing behavior.

Test case updated.
  • Loading branch information
theViz343 authored and neiljp committed Aug 16, 2023
1 parent f268174 commit fad3af0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tests/model/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3919,16 +3919,16 @@ def test_is_muted_topic(
(1, "topic"),
id="unread_present_before_previous_topic",
),
case( # TODO Should be None? (2 other cases)
case(
{(1, "topic")},
(1, "topic"),
(1, "topic"),
None,
id="unread_still_present_in_topic",
),
case(
{},
(1, "topic"),
(1, "topic"),
None,
id="no_unreads_with_previous_topic_state",
),
case({}, None, None, id="no_unreads_with_no_previous_topic_state"),
Expand All @@ -3947,7 +3947,7 @@ def test_is_muted_topic(
case(
{(3, "topic3")},
(2, "topic2"),
(2, "topic2"),
None,
id="unread_present_only_in_muted_stream",
),
case(
Expand Down
2 changes: 2 additions & 0 deletions zulipterminal/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,8 @@ def next_unread_topic_from_message_id(
and not self.is_muted_stream(stream_id)
and next_topic
):
if unread_topic == current_topic:
return None
return unread_topic
if unread_topic == current_topic:
next_topic = True
Expand Down

0 comments on commit fad3af0

Please sign in to comment.