Skip to content

Commit a72eb7b

Browse files
committed
internal_link: Parse topic permalinks
These links (`/with/NNNN`) are just accepted and ignored in this PR, they will be interpreted in #683. Fixes: #684
1 parent 37ad773 commit a72eb7b

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

lib/model/internal_link.dart

+6-2
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ Narrow? _interpretNarrowSegments(List<String> segments, PerAccountStore store) {
178178
if (dmIds == null) return null;
179179
dmElement = ApiNarrowDm(dmIds, negated: negated);
180180

181-
case _NarrowOperator.near:
182-
continue; // TODO(#82): support for near
181+
case _NarrowOperator.near: // TODO(#82): support for near
182+
case _NarrowOperator.With: // TODO(#683): support for with
183+
continue;
183184

184185
case _NarrowOperator.unknown:
185186
return null;
@@ -205,6 +206,9 @@ enum _NarrowOperator {
205206
// 'dm' is new in server-7.0; means the same as 'pm-with'
206207
dm,
207208
near,
209+
// cannot use lowerCamelCase `with` as it is a reserved keyword in Dart
210+
// ignore: constant_identifier_names
211+
With,
208212
pmWith,
209213
stream,
210214
subject,

lib/model/internal_link.g.dart

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/model/internal_link_test.dart

+7
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,12 @@ void main() {
161161
const testCases = [
162162
('/#narrow/stream/check/topic/test', TopicNarrow(1, 'test')),
163163
('/#narrow/stream/mobile/subject/topic/near/378333', TopicNarrow(3, 'topic')),
164+
('/#narrow/stream/mobile/subject/topic/with/1', TopicNarrow(3, 'topic')),
164165
('/#narrow/stream/mobile/topic/topic/', TopicNarrow(3, 'topic')),
165166
('/#narrow/stream/stream/topic/topic/near/1', TopicNarrow(5, 'topic')),
167+
('/#narrow/stream/stream/topic/topic/with/22', TopicNarrow(5, 'topic')),
166168
('/#narrow/stream/stream/subject/topic/near/1', TopicNarrow(5, 'topic')),
169+
('/#narrow/stream/stream/subject/topic/with/333', TopicNarrow(5, 'topic')),
167170
('/#narrow/stream/stream/subject/topic', TopicNarrow(5, 'topic')),
168171
];
169172
testExpectedNarrows(testCases, streams: streams);
@@ -175,7 +178,9 @@ void main() {
175178
final testCases = [
176179
('/#narrow/dm/1,2-group', expectedNarrow),
177180
('/#narrow/dm/1,2-group/near/1', expectedNarrow),
181+
('/#narrow/dm/1,2-group/with/2', expectedNarrow),
178182
('/#narrow/dm/a.40b.2Ecom.2Ec.2Ed.2Ecom/near/3', null),
183+
('/#narrow/dm/a.40b.2Ecom.2Ec.2Ed.2Ecom/with/4', null),
179184
];
180185
testExpectedNarrows(testCases, streams: streams);
181186
});
@@ -186,7 +191,9 @@ void main() {
186191
final testCases = [
187192
('/#narrow/pm-with/1,2-group', expectedNarrow),
188193
('/#narrow/pm-with/1,2-group/near/1', expectedNarrow),
194+
('/#narrow/pm-with/1,2-group/with/2', expectedNarrow),
189195
('/#narrow/pm-with/a.40b.2Ecom.2Ec.2Ed.2Ecom/near/3', null),
196+
('/#narrow/pm-with/a.40b.2Ecom.2Ec.2Ed.2Ecom/with/3', null),
190197
];
191198
testExpectedNarrows(testCases, streams: streams);
192199
});

0 commit comments

Comments
 (0)