diff --git a/lib/model/internal_link.dart b/lib/model/internal_link.dart index 18c8e3affb..cacf8ec3ee 100644 --- a/lib/model/internal_link.dart +++ b/lib/model/internal_link.dart @@ -179,8 +179,9 @@ Narrow? _interpretNarrowSegments(List 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; @@ -206,6 +207,9 @@ enum _NarrowOperator { // 'dm' is new in server-7.0; means the same as 'pm-with' dm, near, + // cannot use `with` as it is a reserved keyword in Dart + @JsonValue('with') + with_, pmWith, stream, channel, diff --git a/lib/model/internal_link.g.dart b/lib/model/internal_link.g.dart index c86b712e1b..7978a3d939 100644 --- a/lib/model/internal_link.g.dart +++ b/lib/model/internal_link.g.dart @@ -11,6 +11,7 @@ part of 'internal_link.dart'; const _$_NarrowOperatorEnumMap = { _NarrowOperator.dm: 'dm', _NarrowOperator.near: 'near', + _NarrowOperator.with_: 'with', _NarrowOperator.pmWith: 'pm-with', _NarrowOperator.stream: 'stream', _NarrowOperator.channel: 'channel', diff --git a/test/model/internal_link_test.dart b/test/model/internal_link_test.dart index eac8a8d023..f7399b3051 100644 --- a/test/model/internal_link_test.dart +++ b/test/model/internal_link_test.dart @@ -172,9 +172,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); @@ -198,7 +201,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); }); @@ -209,7 +214,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); });