Skip to content

Commit 3a57292

Browse files
Khader-1gnprice
authored andcommitted
api [nfc]: Rename UnreadStreamSnapshot to UnreadChannelSnapshot
Fixes parts of zulip#631
1 parent 26fc976 commit 3a57292

7 files changed

+28
-28
lines changed

lib/api/model/initial_snapshot.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class UnreadMessagesSnapshot {
229229
@JsonKey(name: 'pms')
230230
final List<UnreadDmSnapshot> dms;
231231

232-
final List<UnreadStreamSnapshot> streams;
232+
final List<UnreadChannelSnapshot> streams;
233233
final List<UnreadHuddleSnapshot> huddles;
234234

235235
// Unlike other lists of message IDs here, [mentions] is *not* sorted.
@@ -277,21 +277,21 @@ class UnreadDmSnapshot {
277277

278278
/// An item in [UnreadMessagesSnapshot.streams].
279279
@JsonSerializable(fieldRename: FieldRename.snake)
280-
class UnreadStreamSnapshot {
280+
class UnreadChannelSnapshot {
281281
final String topic;
282282
final int streamId;
283283
final List<int> unreadMessageIds;
284284

285-
UnreadStreamSnapshot({
285+
UnreadChannelSnapshot({
286286
required this.topic,
287287
required this.streamId,
288288
required this.unreadMessageIds,
289289
}) : assert(isSortedWithoutDuplicates(unreadMessageIds));
290290

291-
factory UnreadStreamSnapshot.fromJson(Map<String, dynamic> json) =>
292-
_$UnreadStreamSnapshotFromJson(json);
291+
factory UnreadChannelSnapshot.fromJson(Map<String, dynamic> json) =>
292+
_$UnreadChannelSnapshotFromJson(json);
293293

294-
Map<String, dynamic> toJson() => _$UnreadStreamSnapshotToJson(this);
294+
Map<String, dynamic> toJson() => _$UnreadChannelSnapshotToJson(this);
295295
}
296296

297297
/// An item in [UnreadMessagesSnapshot.huddles].

lib/api/model/initial_snapshot.g.dart

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

test/api/model/initial_snapshot_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ void main() {
1515
})).throws<AssertionError>();
1616
});
1717

18-
test('UnreadStreamSnapshot: require sorted unreadMessageIds', () {
19-
check(() => UnreadStreamSnapshot.fromJson({
18+
test('UnreadChannelSnapshot: require sorted unreadMessageIds', () {
19+
check(() => UnreadChannelSnapshot.fromJson({
2020
'topic': 'a',
2121
'stream_id': 1,
2222
'unread_message_ids': [1, 2, 3],
2323
})).returnsNormally();
2424

25-
check(() => UnreadStreamSnapshot.fromJson({
25+
check(() => UnreadChannelSnapshot.fromJson({
2626
'topic': 'a',
2727
'stream_id': 1,
2828
'unread_message_ids': [11, 2, 3],

test/example_data.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ DmMessage dmMessage({
396396
UnreadMessagesSnapshot unreadMsgs({
397397
int? count,
398398
List<UnreadDmSnapshot>? dms,
399-
List<UnreadStreamSnapshot>? streams,
399+
List<UnreadChannelSnapshot>? streams,
400400
List<UnreadHuddleSnapshot>? huddles,
401401
List<int>? mentions,
402402
bool? oldUnreadsMissing,

test/model/unreads_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ void main() {
114114
prepare(initial: UnreadMessagesSnapshot(
115115
count: 0,
116116
streams: [
117-
UnreadStreamSnapshot(streamId: stream1.streamId, topic: 'a', unreadMessageIds: [1, 2]),
118-
UnreadStreamSnapshot(streamId: stream1.streamId, topic: 'b', unreadMessageIds: [3, 4]),
119-
UnreadStreamSnapshot(streamId: stream2.streamId, topic: 'b', unreadMessageIds: [5, 6]),
120-
UnreadStreamSnapshot(streamId: stream2.streamId, topic: 'c', unreadMessageIds: [7, 8]),
117+
UnreadChannelSnapshot(streamId: stream1.streamId, topic: 'a', unreadMessageIds: [1, 2]),
118+
UnreadChannelSnapshot(streamId: stream1.streamId, topic: 'b', unreadMessageIds: [3, 4]),
119+
UnreadChannelSnapshot(streamId: stream2.streamId, topic: 'b', unreadMessageIds: [5, 6]),
120+
UnreadChannelSnapshot(streamId: stream2.streamId, topic: 'c', unreadMessageIds: [7, 8]),
121121
],
122122
dms: [
123123
UnreadDmSnapshot(otherUserId: 1, unreadMessageIds: [9, 10]),

test/widgets/message_list_test.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -866,7 +866,7 @@ void main() {
866866
testWidgets('from unread to read', (WidgetTester tester) async {
867867
final message = eg.streamMessage(flags: []);
868868
final unreadMsgs = eg.unreadMsgs(streams:[
869-
UnreadStreamSnapshot(topic: message.topic, streamId: message.streamId, unreadMessageIds: [message.id])
869+
UnreadChannelSnapshot(topic: message.topic, streamId: message.streamId, unreadMessageIds: [message.id])
870870
]);
871871
await setupMessageListPage(tester, messages: [message], unreadMsgs: unreadMsgs);
872872
check(isMarkAsReadButtonVisible(tester)).isTrue();
@@ -884,7 +884,7 @@ void main() {
884884
testWidgets("messages don't shift position", (WidgetTester tester) async {
885885
final message = eg.streamMessage(flags: []);
886886
final unreadMsgs = eg.unreadMsgs(streams:[
887-
UnreadStreamSnapshot(topic: message.topic, streamId: message.streamId,
887+
UnreadChannelSnapshot(topic: message.topic, streamId: message.streamId,
888888
unreadMessageIds: [message.id])
889889
]);
890890
await setupMessageListPage(tester,
@@ -913,7 +913,7 @@ void main() {
913913

914914
final message = eg.streamMessage(flags: []);
915915
final unreadMsgs = eg.unreadMsgs(streams: [
916-
UnreadStreamSnapshot(streamId: message.streamId, topic: message.topic,
916+
UnreadChannelSnapshot(streamId: message.streamId, topic: message.topic,
917917
unreadMessageIds: [message.id]),
918918
]);
919919

test/widgets/subscription_list_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void main() {
147147
testWidgets('unread badge shows with unreads', (tester) async {
148148
final stream = eg.stream();
149149
final unreadMsgs = eg.unreadMsgs(streams: [
150-
UnreadStreamSnapshot(streamId: stream.streamId, topic: 'a', unreadMessageIds: [1, 2]),
150+
UnreadChannelSnapshot(streamId: stream.streamId, topic: 'a', unreadMessageIds: [1, 2]),
151151
]);
152152
await setupStreamListPage(tester, subscriptions: [
153153
eg.subscription(stream),
@@ -158,8 +158,8 @@ void main() {
158158
testWidgets('unread badge counts unmuted only', (tester) async {
159159
final stream = eg.stream();
160160
final unreadMsgs = eg.unreadMsgs(streams: [
161-
UnreadStreamSnapshot(streamId: stream.streamId, topic: 'a', unreadMessageIds: [1, 2]),
162-
UnreadStreamSnapshot(streamId: stream.streamId, topic: 'b', unreadMessageIds: [3]),
161+
UnreadChannelSnapshot(streamId: stream.streamId, topic: 'a', unreadMessageIds: [1, 2]),
162+
UnreadChannelSnapshot(streamId: stream.streamId, topic: 'b', unreadMessageIds: [3]),
163163
]);
164164
await setupStreamListPage(tester,
165165
subscriptions: [eg.subscription(stream, isMuted: true)],
@@ -187,7 +187,7 @@ void main() {
187187
testWidgets('color propagates to icon and badge', (tester) async {
188188
final stream = eg.stream();
189189
final unreadMsgs = eg.unreadMsgs(streams: [
190-
UnreadStreamSnapshot(streamId: stream.streamId, topic: 'a', unreadMessageIds: [1, 2]),
190+
UnreadChannelSnapshot(streamId: stream.streamId, topic: 'a', unreadMessageIds: [1, 2]),
191191
]);
192192
final subscription = eg.subscription(stream, color: Colors.red.value);
193193
final swatch = StreamColorSwatch.light(subscription.color);
@@ -225,8 +225,8 @@ void main() {
225225
eg.userTopicItem(stream2, 'b', UserTopicVisibilityPolicy.unmuted),
226226
],
227227
unreadMsgs: eg.unreadMsgs(streams: [
228-
UnreadStreamSnapshot(streamId: stream1.streamId, topic: 'a', unreadMessageIds: [1, 2]),
229-
UnreadStreamSnapshot(streamId: stream2.streamId, topic: 'b', unreadMessageIds: [3]),
228+
UnreadChannelSnapshot(streamId: stream1.streamId, topic: 'a', unreadMessageIds: [1, 2]),
229+
UnreadChannelSnapshot(streamId: stream2.streamId, topic: 'b', unreadMessageIds: [3]),
230230
]),
231231
);
232232

0 commit comments

Comments
 (0)