Skip to content

Commit ebb41b6

Browse files
sm-sayedignprice
authored andcommitted
internal_link: Parse topic permalinks
This `with` operator (as in `/with/NNNN`) is just accepted and ignored as of this change. Interpreting them is zulip#683. Fixes: zulip#684
1 parent 50eba89 commit ebb41b6

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
@@ -179,8 +179,9 @@ Narrow? _interpretNarrowSegments(List<String> segments, PerAccountStore store) {
179179
if (dmIds == null) return null;
180180
dmElement = ApiNarrowDm(dmIds, negated: negated);
181181

182-
case _NarrowOperator.near:
183-
continue; // TODO(#82): support for near
182+
case _NarrowOperator.near: // TODO(#82): support for near
183+
case _NarrowOperator.with_: // TODO(#683): support for with
184+
continue;
184185

185186
case _NarrowOperator.unknown:
186187
return null;
@@ -206,6 +207,9 @@ enum _NarrowOperator {
206207
// 'dm' is new in server-7.0; means the same as 'pm-with'
207208
dm,
208209
near,
210+
// cannot use `with` as it is a reserved keyword in Dart
211+
@JsonValue('with')
212+
with_,
209213
pmWith,
210214
stream,
211215
channel,

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
@@ -172,9 +172,12 @@ void main() {
172172
const testCases = [
173173
('/#narrow/stream/check/topic/test', TopicNarrow(1, 'test')),
174174
('/#narrow/stream/mobile/subject/topic/near/378333', TopicNarrow(3, 'topic')),
175+
('/#narrow/stream/mobile/subject/topic/with/1', TopicNarrow(3, 'topic')),
175176
('/#narrow/stream/mobile/topic/topic/', TopicNarrow(3, 'topic')),
176177
('/#narrow/stream/stream/topic/topic/near/1', TopicNarrow(5, 'topic')),
178+
('/#narrow/stream/stream/topic/topic/with/22', TopicNarrow(5, 'topic')),
177179
('/#narrow/stream/stream/subject/topic/near/1', TopicNarrow(5, 'topic')),
180+
('/#narrow/stream/stream/subject/topic/with/333', TopicNarrow(5, 'topic')),
178181
('/#narrow/stream/stream/subject/topic', TopicNarrow(5, 'topic')),
179182
];
180183
testExpectedNarrows(testCases, streams: streams);
@@ -198,7 +201,9 @@ void main() {
198201
final testCases = [
199202
('/#narrow/dm/1,2-group', expectedNarrow),
200203
('/#narrow/dm/1,2-group/near/1', expectedNarrow),
204+
('/#narrow/dm/1,2-group/with/2', expectedNarrow),
201205
('/#narrow/dm/a.40b.2Ecom.2Ec.2Ed.2Ecom/near/3', null),
206+
('/#narrow/dm/a.40b.2Ecom.2Ec.2Ed.2Ecom/with/4', null),
202207
];
203208
testExpectedNarrows(testCases, streams: streams);
204209
});
@@ -209,7 +214,9 @@ void main() {
209214
final testCases = [
210215
('/#narrow/pm-with/1,2-group', expectedNarrow),
211216
('/#narrow/pm-with/1,2-group/near/1', expectedNarrow),
217+
('/#narrow/pm-with/1,2-group/with/2', expectedNarrow),
212218
('/#narrow/pm-with/a.40b.2Ecom.2Ec.2Ed.2Ecom/near/3', null),
219+
('/#narrow/pm-with/a.40b.2Ecom.2Ec.2Ed.2Ecom/with/3', null),
213220
];
214221
testExpectedNarrows(testCases, streams: streams);
215222
});

0 commit comments

Comments
 (0)