diff --git a/lib/model/internal_link.dart b/lib/model/internal_link.dart index 7276225603..37dc4eed87 100644 --- a/lib/model/internal_link.dart +++ b/lib/model/internal_link.dart @@ -178,8 +178,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; @@ -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, diff --git a/lib/model/internal_link.g.dart b/lib/model/internal_link.g.dart index 7a6952c5d5..c28306414c 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.subject: 'subject', diff --git a/test/model/internal_link_test.dart b/test/model/internal_link_test.dart index 4b4a4b625e..12633b6673 100644 --- a/test/model/internal_link_test.dart +++ b/test/model/internal_link_test.dart @@ -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); @@ -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); }); @@ -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); });