Skip to content

Commit

Permalink
narrow: Make getNarrowForReply stop returning stream narrows.
Browse files Browse the repository at this point in the history
There's no reason we would sometimes want a stream narrow here. This
is just how it was when this function was first written (as
`getNarrowFromMessage`), for narrowing to a message's conversation,
in 34ab1f9 (zulip#333) in 2017.

This case also should be impossible anyway, because message topics
should always be nonempty -- we convert empty to "(no topic)".

Co-authored-by: Chris Bobbe <cbobbe@zulip.com>
  • Loading branch information
gnprice and chrisbobbe committed Nov 25, 2020
1 parent e8cb18b commit 5bf51c7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
9 changes: 0 additions & 9 deletions src/utils/__tests__/narrow-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,6 @@ describe('getNarrowForReply', () => {
expect(actualNarrow).toEqual(expectedNarrow);
});

test('if recipient of a message is string, returns a stream narrow', () => {
const message = eg.streamMessage({ subject: '' });
const expectedNarrow = streamNarrow(eg.stream.name);

const actualNarrow = getNarrowForReply(message, ownEmail);

expect(actualNarrow).toEqual(expectedNarrow);
});

test('if recipient is a string and there is a subject returns a topic narrow', () => {
const message = eg.streamMessage();
const expectedNarrow = topicNarrow(eg.stream.name, message.subject);
Expand Down
6 changes: 1 addition & 5 deletions src/utils/narrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,5 @@ export const getNarrowForReply = (message: Message | Outbox, ownEmail: string) =
}
}

if (message.subject && message.subject.length) {
return topicNarrow(message.display_recipient, message.subject);
}

return streamNarrow(message.display_recipient);
return topicNarrow(message.display_recipient, message.subject);
};

0 comments on commit 5bf51c7

Please sign in to comment.