Skip to content

Commit

Permalink
wip narrow: getNarrowFromMessage never a stream narrow
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, 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)".
  • Loading branch information
gnprice committed Dec 8, 2020
1 parent d284584 commit dd60149
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
10 changes: 0 additions & 10 deletions src/utils/__tests__/narrow-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -327,16 +327,6 @@ describe('getNarrowFromMessage', () => {
expect(actualNarrow).toEqual(expectedNarrow);
});

test('for stream message with empty topic, returns a stream narrow', () => {
// TODO this behavior seems pretty dubious
const message = eg.streamMessage({ subject: '' });
const expectedNarrow = streamNarrow(eg.stream.name);

const actualNarrow = getNarrowFromMessage(message, eg.selfUser);

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

test('for stream message with nonempty topic, returns a topic narrow', () => {
const message = eg.streamMessage();
const expectedNarrow = topicNarrow(eg.stream.name, message.subject);
Expand Down
5 changes: 1 addition & 4 deletions src/utils/narrow.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,6 @@ export const getNarrowFromMessage = (message: Message | Outbox, ownUser: User) =
} else {
const streamName = streamNameOfStreamMessage(message);
const topic = message.subject;
if (topic && topic.length) {
return topicNarrow(streamName, topic);
}
return streamNarrow(streamName);
return topicNarrow(streamName, topic);
}
};

0 comments on commit dd60149

Please sign in to comment.