Skip to content

Commit 9739ec0

Browse files
committed
narrow: Implement toString on {Stream,Topic,Dm}Narrow classes
This will be helpful for test-failure output, particularly with DmNarrows as we start using those as Map keys, soon. Of our current Narrow subclasses, this just leaves AllMessagesNarrow without a custom `toString` implementation. That's OK, because the default `toString` already says "AllMessagesNarrow", which is all we need to know about the narrow.
1 parent 37c5a4a commit 9739ec0

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/model/narrow.dart

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class StreamNarrow extends Narrow {
7070
@override
7171
ApiNarrow apiEncode() => [ApiNarrowStream(streamId)];
7272

73+
@override
74+
String toString() => 'StreamNarrow($streamId)';
75+
7376
@override
7477
bool operator ==(Object other) {
7578
if (other is! StreamNarrow) return false;
@@ -102,6 +105,9 @@ class TopicNarrow extends Narrow implements SendableNarrow {
102105
@override
103106
StreamDestination get destination => StreamDestination(streamId, topic);
104107

108+
@override
109+
String toString() => 'TopicNarrow($streamId, $topic)';
110+
105111
@override
106112
bool operator ==(Object other) {
107113
if (other is! TopicNarrow) return false;
@@ -207,6 +213,9 @@ class DmNarrow extends Narrow implements SendableNarrow {
207213
@override
208214
ApiNarrow apiEncode() => [ApiNarrowDm(allRecipientIds)];
209215

216+
@override
217+
String toString() => 'DmNarrow(allRecipientIds: $allRecipientIds)';
218+
210219
@override
211220
bool operator ==(Object other) {
212221
if (other is! DmNarrow) return false;

0 commit comments

Comments
 (0)