Skip to content

Commit a783ced

Browse files
committed
internal_link: Allow duplicates of the same is operand.
This matches the behavior of the webapp. Such narrow links are semantically valid and equivalent to the deduplicated link. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 4c0bafc commit a783ced

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/model/internal_link.dart

+2-3
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,8 @@ Narrow? _interpretNarrowSegments(List<String> segments, PerAccountStore store) {
181181
dmElement = ApiNarrowDm(dmIds, negated: negated);
182182

183183
case _NarrowOperator.is_:
184-
final isElementOperand = IsOperand.fromRawString(operand);
185-
if (isElementOperands.contains(isElementOperand)) return null;
186-
isElementOperands.add(isElementOperand);
184+
// It is fine to have duplicates of the same [IsOperand].
185+
isElementOperands.add(IsOperand.fromRawString(operand));
187186

188187
case _NarrowOperator.near: // TODO(#82): support for near
189188
case _NarrowOperator.with_: // TODO(#683): support for with

test/model/internal_link_test.dart

+1
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ void main() {
228228
for (final operand in IsOperand.values) {
229229
List<(String, Narrow?)> sharedCases(Narrow? narrow) => [
230230
('/#narrow/is/$operand', narrow),
231+
('/#narrow/is/$operand/is/$operand', narrow),
231232
('/#narrow/is/$operand/near/1', narrow),
232233
('/#narrow/is/$operand/with/2', narrow),
233234
('/#narrow/channel/7-test-here/is/$operand', null),

0 commit comments

Comments
 (0)