Skip to content

Commit

Permalink
internal_link: Parse topic permalinks
Browse files Browse the repository at this point in the history
These links (`/with/NNNN`) are just accepted and ignored in this PR,
they will be interpreted in zulip#683.

Fixes: zulip#684
  • Loading branch information
sm-sayedi committed Jun 11, 2024
1 parent 37ad773 commit a72eb7b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/model/internal_link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,9 @@ Narrow? _interpretNarrowSegments(List<String> segments, PerAccountStore store) {
if (dmIds == null) return null;
dmElement = ApiNarrowDm(dmIds, negated: negated);

case _NarrowOperator.near:
continue; // TODO(#82): support for near
case _NarrowOperator.near: // TODO(#82): support for near
case _NarrowOperator.With: // TODO(#683): support for with
continue;

case _NarrowOperator.unknown:
return null;
Expand All @@ -205,6 +206,9 @@ enum _NarrowOperator {
// 'dm' is new in server-7.0; means the same as 'pm-with'
dm,
near,
// cannot use lowerCamelCase `with` as it is a reserved keyword in Dart
// ignore: constant_identifier_names
With,
pmWith,
stream,
subject,
Expand Down
1 change: 1 addition & 0 deletions lib/model/internal_link.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions test/model/internal_link_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,12 @@ void main() {
const testCases = [
('/#narrow/stream/check/topic/test', TopicNarrow(1, 'test')),
('/#narrow/stream/mobile/subject/topic/near/378333', TopicNarrow(3, 'topic')),
('/#narrow/stream/mobile/subject/topic/with/1', TopicNarrow(3, 'topic')),
('/#narrow/stream/mobile/topic/topic/', TopicNarrow(3, 'topic')),
('/#narrow/stream/stream/topic/topic/near/1', TopicNarrow(5, 'topic')),
('/#narrow/stream/stream/topic/topic/with/22', TopicNarrow(5, 'topic')),
('/#narrow/stream/stream/subject/topic/near/1', TopicNarrow(5, 'topic')),
('/#narrow/stream/stream/subject/topic/with/333', TopicNarrow(5, 'topic')),
('/#narrow/stream/stream/subject/topic', TopicNarrow(5, 'topic')),
];
testExpectedNarrows(testCases, streams: streams);
Expand All @@ -175,7 +178,9 @@ void main() {
final testCases = [
('/#narrow/dm/1,2-group', expectedNarrow),
('/#narrow/dm/1,2-group/near/1', expectedNarrow),
('/#narrow/dm/1,2-group/with/2', expectedNarrow),
('/#narrow/dm/a.40b.2Ecom.2Ec.2Ed.2Ecom/near/3', null),
('/#narrow/dm/a.40b.2Ecom.2Ec.2Ed.2Ecom/with/4', null),
];
testExpectedNarrows(testCases, streams: streams);
});
Expand All @@ -186,7 +191,9 @@ void main() {
final testCases = [
('/#narrow/pm-with/1,2-group', expectedNarrow),
('/#narrow/pm-with/1,2-group/near/1', expectedNarrow),
('/#narrow/pm-with/1,2-group/with/2', expectedNarrow),
('/#narrow/pm-with/a.40b.2Ecom.2Ec.2Ed.2Ecom/near/3', null),
('/#narrow/pm-with/a.40b.2Ecom.2Ec.2Ed.2Ecom/with/3', null),
];
testExpectedNarrows(testCases, streams: streams);
});
Expand Down

0 comments on commit a72eb7b

Please sign in to comment.