Skip to content

Commit 5eb3e75

Browse files
committed
api [nfc]: Rename ZulipStream to Channel
Fixes parts of zulip#631
1 parent 51e01f4 commit 5eb3e75

19 files changed

+51
-54
lines changed

lib/api/model/events.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ class StreamCreateEvent extends StreamEvent {
347347
@override
348348
String get op => 'create';
349349

350-
final List<ZulipStream> streams;
350+
final List<Channel> streams;
351351

352352
StreamCreateEvent({required super.id, required this.streams});
353353

@@ -364,7 +364,7 @@ class StreamDeleteEvent extends StreamEvent {
364364
@override
365365
String get op => 'delete';
366366

367-
final List<ZulipStream> streams;
367+
final List<Channel> streams;
368368

369369
StreamDeleteEvent({required super.id, required this.streams});
370370

lib/api/model/events.g.dart

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/api/model/initial_snapshot.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class InitialSnapshot {
3434

3535
final UnreadMessagesSnapshot unreadMsgs;
3636

37-
final List<ZulipStream> streams;
37+
final List<Channel> streams;
3838

3939
// Servers pre-5.0 don't have `user_settings`, and instead provide whatever
4040
// user settings they support at toplevel in the initial snapshot. Since we're

lib/api/model/initial_snapshot.g.dart

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/api/model/model.dart

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -302,12 +302,10 @@ enum UserRole{
302302

303303
/// As in `streams` in the initial snapshot.
304304
///
305-
/// Not called `Stream` because dart:async uses that name.
306-
///
307305
/// For docs, search for "if stream"
308306
/// in <https://zulip.com/api/register-queue>.
309307
@JsonSerializable(fieldRename: FieldRename.snake)
310-
class ZulipStream {
308+
class Channel {
311309
final int streamId;
312310
final String name;
313311
final String description;
@@ -337,7 +335,7 @@ class ZulipStream {
337335
?? (json['can_remove_subscribers_group_id'] as int?);
338336
}
339337

340-
ZulipStream({
338+
Channel({
341339
required this.streamId,
342340
required this.name,
343341
required this.description,
@@ -353,10 +351,10 @@ class ZulipStream {
353351
required this.streamWeeklyTraffic,
354352
});
355353

356-
factory ZulipStream.fromJson(Map<String, dynamic> json) =>
357-
_$ZulipStreamFromJson(json);
354+
factory Channel.fromJson(Map<String, dynamic> json) =>
355+
_$ChannelFromJson(json);
358356

359-
Map<String, dynamic> toJson() => _$ZulipStreamToJson(this);
357+
Map<String, dynamic> toJson() => _$ChannelToJson(this);
360358
}
361359

362360
/// Policy for which users can post to the stream.
@@ -385,7 +383,7 @@ enum StreamPostPolicy {
385383
/// For docs, search for "subscriptions:"
386384
/// in <https://zulip.com/api/register-queue>.
387385
@JsonSerializable(fieldRename: FieldRename.snake)
388-
class Subscription extends ZulipStream {
386+
class Subscription extends Channel {
389387
// final List<int> subscribers; // we register with includeSubscribers false
390388

391389
bool? desktopNotifications;

lib/api/model/model.g.dart

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/model/store.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,9 @@ class PerAccountStore extends ChangeNotifier with StreamStore, MessageStore {
323323
// Streams, topics, and stuff about them.
324324

325325
@override
326-
Map<int, ZulipStream> get streams => _streams.streams;
326+
Map<int, Channel> get streams => _streams.streams;
327327
@override
328-
Map<String, ZulipStream> get streamsByName => _streams.streamsByName;
328+
Map<String, Channel> get streamsByName => _streams.streamsByName;
329329
@override
330330
Map<int, Subscription> get subscriptions => _streams.subscriptions;
331331
@override

lib/model/stream.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import '../api/model/model.dart';
99
///
1010
/// The data structures described here are implemented at [StreamStoreImpl].
1111
mixin StreamStore {
12-
Map<int, ZulipStream> get streams;
13-
Map<String, ZulipStream> get streamsByName;
12+
Map<int, Channel> get streams;
13+
Map<String, Channel> get streamsByName;
1414
Map<int, Subscription> get subscriptions;
1515
UserTopicVisibilityPolicy topicVisibilityPolicy(int streamId, String topic);
1616

@@ -77,7 +77,7 @@ class StreamStoreImpl with StreamStore {
7777
final subscriptions = Map.fromEntries(initialSnapshot.subscriptions.map(
7878
(subscription) => MapEntry(subscription.streamId, subscription)));
7979

80-
final streams = Map<int, ZulipStream>.of(subscriptions);
80+
final streams = Map<int, Channel>.of(subscriptions);
8181
for (final stream in initialSnapshot.streams) {
8282
streams.putIfAbsent(stream.streamId, () => stream);
8383
}
@@ -108,9 +108,9 @@ class StreamStoreImpl with StreamStore {
108108
});
109109

110110
@override
111-
final Map<int, ZulipStream> streams;
111+
final Map<int, Channel> streams;
112112
@override
113-
final Map<String, ZulipStream> streamsByName;
113+
final Map<String, Channel> streamsByName;
114114
@override
115115
final Map<int, Subscription> subscriptions;
116116

lib/widgets/icons.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,13 @@ abstract final class ZulipIcons {
7878
// END GENERATED ICON DATA
7979
}
8080

81-
IconData iconDataForStream(ZulipStream stream) {
81+
IconData iconDataForStream(Channel stream) {
8282
// TODO: these icons aren't quite right yet;
8383
// see this message and the one after it:
8484
// https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/design.3A.20.23F117.20.22Inbox.22.20screen/near/1680637
8585
return switch(stream) {
86-
ZulipStream(isWebPublic: true) => ZulipIcons.globe,
87-
ZulipStream(inviteOnly: true) => ZulipIcons.lock,
88-
ZulipStream() => ZulipIcons.hash_sign,
86+
Channel(isWebPublic: true) => ZulipIcons.globe,
87+
Channel(inviteOnly: true) => ZulipIcons.lock,
88+
Channel() => ZulipIcons.hash_sign,
8989
};
9090
}

lib/widgets/message_list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ class MessageListAppBarTitle extends StatelessWidget {
124124
final Narrow narrow;
125125

126126
Widget _buildStreamRow(BuildContext context, {
127-
ZulipStream? stream,
127+
Channel? stream,
128128
required String text,
129129
}) {
130130
// A null [Icon.icon] makes a blank space.

test/api/model/model_checks.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ extension UserChecks on Subject<User> {
2323
Subject<bool> get isSystemBot => has((x) => x.isSystemBot, 'isSystemBot');
2424
}
2525

26-
extension ZulipStreamChecks on Subject<ZulipStream> {
26+
extension ChannelChecks on Subject<Channel> {
2727
Subject<int?> get canRemoveSubscribersGroup => has((e) => e.canRemoveSubscribersGroup, 'canRemoveSubscribersGroup');
2828
}
2929

test/api/model/model_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void main() {
6666
});
6767
});
6868

69-
group('ZulipStream.canRemoveSubscribersGroup', () {
69+
group('Channel.canRemoveSubscribersGroup', () {
7070
final Map<String, dynamic> baseJson = Map.unmodifiable({
7171
'stream_id': 123,
7272
'name': 'A stream',
@@ -84,21 +84,21 @@ void main() {
8484
});
8585

8686
test('smoke', () {
87-
check(ZulipStream.fromJson({ ...baseJson,
87+
check(Channel.fromJson({ ...baseJson,
8888
'can_remove_subscribers_group': 123,
8989
})).canRemoveSubscribersGroup.equals(123);
9090
});
9191

9292
// TODO(server-8): field renamed in FL 197
9393
test('support old can_remove_subscribers_group_id', () {
94-
check(ZulipStream.fromJson({ ...baseJson,
94+
check(Channel.fromJson({ ...baseJson,
9595
'can_remove_subscribers_group_id': 456,
9696
})).canRemoveSubscribersGroup.equals(456);
9797
});
9898

9999
// TODO(server-6): field added in FL 142
100100
test('support field missing', () {
101-
check(ZulipStream.fromJson({ ...baseJson,
101+
check(Channel.fromJson({ ...baseJson,
102102
})).canRemoveSubscribersGroup.isNull();
103103
});
104104
});

test/example_data.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ final User fourthUser = user(fullName: 'Fourth User', email: 'fourth@example');
149149
// Streams and subscriptions.
150150
//
151151

152-
ZulipStream stream({
152+
Channel stream({
153153
int? streamId,
154154
String? name,
155155
String? description,
@@ -164,7 +164,7 @@ ZulipStream stream({
164164
int? canRemoveSubscribersGroup,
165165
int? streamWeeklyTraffic,
166166
}) {
167-
return ZulipStream(
167+
return Channel(
168168
streamId: streamId ?? 123, // TODO generate example IDs
169169
name: name ?? 'A stream', // TODO generate example names
170170
description: description ?? 'A description', // TODO generate example descriptions
@@ -185,9 +185,9 @@ const _stream = stream;
185185
/// Construct an example subscription from a stream.
186186
///
187187
/// We only allow overrides of values specific to the [Subscription], all
188-
/// other properties are copied from the [ZulipStream] provided.
188+
/// other properties are copied from the [Channel] provided.
189189
Subscription subscription(
190-
ZulipStream stream, {
190+
Channel stream, {
191191
bool? desktopNotifications,
192192
bool? emailNotifications,
193193
bool? wildcardMentionsNotify,
@@ -294,7 +294,7 @@ int _lastMessageId = 1000;
294294
StreamMessage streamMessage({
295295
int? id,
296296
User? sender,
297-
ZulipStream? stream,
297+
Channel? stream,
298298
String? topic,
299299
String? content,
300300
String? contentMarkdown,
@@ -537,7 +537,7 @@ InitialSnapshot initialSnapshot({
537537
List<RecentDmConversation>? recentPrivateConversations,
538538
List<Subscription>? subscriptions,
539539
UnreadMessagesSnapshot? unreadMsgs,
540-
List<ZulipStream>? streams,
540+
List<Channel>? streams,
541541
UserSettings? userSettings,
542542
List<UserTopicItem>? userTopics,
543543
Map<String, RealmDefaultExternalAccount>? realmDefaultExternalAccounts,

test/model/internal_link_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Set<String> getUrlSyntaxVariants(String urlString) {
1818

1919
Future<PerAccountStore> setupStore({
2020
required Uri realmUrl,
21-
List<ZulipStream>? streams,
21+
List<Channel>? streams,
2222
List<User>? users,
2323
}) async {
2424
final account = eg.selfAccount.copyWith(realmUrl: realmUrl);
@@ -37,7 +37,7 @@ void main() {
3737
final realmUrl = Uri.parse('https://example.com/');
3838

3939
void testExpectedNarrows(List<(String, Narrow?)> testCases, {
40-
List<ZulipStream>? streams,
40+
List<Channel>? streams,
4141
List<User>? users,
4242
}) {
4343
assert(streams != null || users != null);

test/model/store_checks.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ extension PerAccountStoreChecks on Subject<PerAccountStore> {
3939
Subject<int> get selfUserId => has((x) => x.selfUserId, 'selfUserId');
4040
Subject<UserSettings?> get userSettings => has((x) => x.userSettings, 'userSettings');
4141
Subject<Map<int, User>> get users => has((x) => x.users, 'users');
42-
Subject<Map<int, ZulipStream>> get streams => has((x) => x.streams, 'streams');
43-
Subject<Map<String, ZulipStream>> get streamsByName => has((x) => x.streamsByName, 'streamsByName');
42+
Subject<Map<int, Channel>> get streams => has((x) => x.streams, 'streams');
43+
Subject<Map<String, Channel>> get streamsByName => has((x) => x.streamsByName, 'streamsByName');
4444
Subject<Map<int, Subscription>> get subscriptions => has((x) => x.subscriptions, 'subscriptions');
4545
Subject<Map<int, Message>> get messages => has((x) => x.messages, 'messages');
4646
Subject<Unreads> get unreads => has((x) => x.unreads, 'unreads');

test/model/stream_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ void main() {
190190
});
191191

192192
UserTopicItem makeUserTopicItem(
193-
ZulipStream stream, String topic, UserTopicVisibilityPolicy policy) {
193+
Channel stream, String topic, UserTopicVisibilityPolicy policy) {
194194
return UserTopicItem(
195195
streamId: stream.streamId,
196196
topicName: topic,

test/model/test_store.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,11 @@ extension PerAccountStoreTestExtension on PerAccountStore {
129129
}
130130
}
131131

132-
Future<void> addStream(ZulipStream stream) async {
132+
Future<void> addStream(Channel stream) async {
133133
await addStreams([stream]);
134134
}
135135

136-
Future<void> addStreams(List<ZulipStream> streams) async {
136+
Future<void> addStreams(List<Channel> streams) async {
137137
await handleEvent(StreamCreateEvent(id: 1, streams: streams));
138138
}
139139

@@ -145,7 +145,7 @@ extension PerAccountStoreTestExtension on PerAccountStore {
145145
await handleEvent(SubscriptionAddEvent(id: 1, subscriptions: subscriptions));
146146
}
147147

148-
Future<void> addUserTopic(ZulipStream stream, String topic, UserTopicVisibilityPolicy visibilityPolicy) async {
148+
Future<void> addUserTopic(Channel stream, String topic, UserTopicVisibilityPolicy visibilityPolicy) async {
149149
await handleEvent(UserTopicEvent(
150150
id: 1,
151151
streamId: stream.streamId,

test/widgets/inbox_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void main() {
5252
late PerAccountStore store;
5353

5454
Future<void> setupPage(WidgetTester tester, {
55-
List<ZulipStream>? streams,
55+
List<Channel>? streams,
5656
List<Subscription>? subscriptions,
5757
List<User>? users,
5858
required List<Message> unreadMessages,
@@ -82,7 +82,7 @@ void main() {
8282
}
8383

8484
List<StreamMessage> generateStreamMessages({
85-
required ZulipStream stream,
85+
required Channel stream,
8686
required int count,
8787
required List<MessageFlag> flags,
8888
}) {

test/widgets/message_list_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void main() {
4646
bool foundOldest = true,
4747
int? messageCount,
4848
List<Message>? messages,
49-
List<ZulipStream>? streams,
49+
List<Channel>? streams,
5050
List<User>? users,
5151
List<Subscription>? subscriptions,
5252
UnreadMessagesSnapshot? unreadMsgs,
@@ -374,7 +374,7 @@ void main() {
374374
testWidgets('show stream name from stream data when known', (tester) async {
375375
final streamBefore = eg.stream(name: 'old stream name');
376376
// TODO(#182) this test would be more realistic using a StreamUpdateEvent
377-
final streamAfter = ZulipStream.fromJson({
377+
final streamAfter = Channel.fromJson({
378378
...(deepToJson(streamBefore) as Map<String, dynamic>),
379379
'name': 'new stream name',
380380
});

0 commit comments

Comments
 (0)