-
Notifications
You must be signed in to change notification settings - Fork 321
internal_link: Generate new narrow links with "channel", not "stream" #1795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
internal_link: Generate new narrow links with "channel", not "stream" #1795
Conversation
a7dcdf3
to
ba367d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, LGTM! Marking for Greg's review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking care of this! Generally this looks good; a few comments below.
lib/model/internal_link.dart
Outdated
case ApiNarrowChannelModern(): | ||
case ApiNarrowStream(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: since these are handled the same way here, they can continue to use the base class with its simpler name:
case ApiNarrowChannelModern(): | |
case ApiNarrowStream(): | |
case ApiNarrowChannel(): |
(There still shouldn't be an instance of directly the base class here, because the operator
getter above would complain. But this code doesn't need to go out of its way to detect that.)
This differs from the ApiNarrowDm logic below, because for that one the operand looks different between the two cases.
checkNarrow(eg.topicNarrow(12, 'stuff', with_: 1).apiEncode(), jsonEncode([ | ||
{'operator': 'stream', 'operand': 12}, | ||
{'operator': 'channel', 'operand': 12}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test change shows that the effect of this commit is a bit broader than what the commit message says:
internal_link: Generate new narrow links with "channel", not "stream"
It's also changing the get-messages requests we make to the server.
I think it's fine for that to happen in the same commit; given the way ApiNarrow works, I think splitting those changes into separate commits would require complicating the logic. But the commit message should be adjusted to make that clear.
test/model/compose_test.dart
Outdated
check(quoteAndReply(store, message: message, rawContent: 'Hello world!')).equals(''' | ||
@_**Full Name|123** [said](${eg.selfAccount.realmUrl}#narrow/stream/1-test-here/topic/some.20topic/near/${message.id}): | ||
@_**Full Name|123** [said](${eg.selfAccount.realmUrl}#narrow/channel/1-test-here/topic/some.20topic/near/${message.id}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also have a test checking that these still use the old form when talking to an old server.
test/model/internal_link_test.dart
Outdated
test('legacy including "stream" operator', () { | ||
checkNarrow(streamId: 1, name: 'announce', zulipFeatureLevel: 249, | ||
'#narrow/stream/1-announce'); | ||
checkNarrow(streamId: 378, name: 'api design', zulipFeatureLevel: 249, | ||
'#narrow/stream/378-api-design'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the different cases within the existing test here (and the new 'modern including "channel" operator' test) are here to exercise things like
- there's a topic;
- there's a /near/ operator;
- the channel name and/or topic have various characters that do, or might, get encoded in nontrivial ways.
Those don't really interact with the channel-vs-stream thing, though. So this "legacy" test can be cut down to just one or two examples; I think that will tell all the same story of how the legacy case differs from the modern case, without extra details that distract from that story.
ba367d6
to
0d29651
Compare
Thanks @gnprice for the review. New revision pushed. |
c55db48
to
7a81123
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Just one nit below; otherwise all looks good.
@@ -93,17 +98,51 @@ sealed class ApiNarrowElement { | |||
}; | |||
} | |||
|
|||
class ApiNarrowStream extends ApiNarrowElement { | |||
@override String get operator => 'stream'; | |||
class ApiNarrowChannel extends ApiNarrowElement { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
This change affects few places in the app, for example, generating
internal links and sending api request with the new "channel" operator.
s/few/a few/
Perhaps confusingly, the meaning of "few" and the meaning of "a few" point in opposite directions: "few" means the number is small, while "a few" means it's larger than one or two. So "affects few places" is a way of saying "don't worry, this doesn't affect much", which isn't the point you're aiming to make here.
This change affects a few places in the app, for example, generating internal links and sending api request with the new "channel" operator. Fixes: zulip#633
7a81123
to
385fb81
Compare
Thanks for the review and the point mentioned. Changes pushed. |
Thanks! Looks good; merging. |
Replaces #781.
Fixes: #633