Skip to content

Commit 1e979a3

Browse files
Khader-1gnprice
authored andcommitted
channel [nfc]: Rename StreamStore/Impl to ChannelStore/Impl, and rename file
Fixes parts of #631
1 parent 157c685 commit 1e979a3

File tree

7 files changed

+26
-26
lines changed

7 files changed

+26
-26
lines changed

lib/model/stream.dart renamed to lib/model/channel.dart

+9-9
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import '../api/model/events.dart';
22
import '../api/model/initial_snapshot.dart';
33
import '../api/model/model.dart';
44

5-
/// The portion of [PerAccountStore] for streams, topics, and stuff about them.
5+
/// The portion of [PerAccountStore] for channels, topics, and stuff about them.
66
///
77
/// This type is useful for expressing the needs of other parts of the
88
/// implementation of [PerAccountStore], to avoid circularity.
99
///
10-
/// The data structures described here are implemented at [StreamStoreImpl].
11-
mixin StreamStore {
10+
/// The data structures described here are implemented at [ChannelStoreImpl].
11+
mixin ChannelStore {
1212
Map<int, ZulipStream> get streams;
1313
Map<String, ZulipStream> get streamsByName;
1414
Map<int, Subscription> get subscriptions;
@@ -67,13 +67,13 @@ mixin StreamStore {
6767
}
6868
}
6969

70-
/// The implementation of [StreamStore] that does the work.
70+
/// The implementation of [ChannelStore] that does the work.
7171
///
7272
/// Generally the only code that should need this class is [PerAccountStore]
7373
/// itself. Other code accesses this functionality through [PerAccountStore],
74-
/// or through the mixin [StreamStore] which describes its interface.
75-
class StreamStoreImpl with StreamStore {
76-
factory StreamStoreImpl({required InitialSnapshot initialSnapshot}) {
74+
/// or through the mixin [ChannelStore] which describes its interface.
75+
class ChannelStoreImpl with ChannelStore {
76+
factory ChannelStoreImpl({required InitialSnapshot initialSnapshot}) {
7777
final subscriptions = Map.fromEntries(initialSnapshot.subscriptions.map(
7878
(subscription) => MapEntry(subscription.streamId, subscription)));
7979

@@ -92,15 +92,15 @@ class StreamStoreImpl with StreamStore {
9292
forStream[item.topicName] = item.visibilityPolicy;
9393
}
9494

95-
return StreamStoreImpl._(
95+
return ChannelStoreImpl._(
9696
streams: streams,
9797
streamsByName: streams.map((_, stream) => MapEntry(stream.name, stream)),
9898
subscriptions: subscriptions,
9999
topicVisibility: topicVisibility,
100100
);
101101
}
102102

103-
StreamStoreImpl._({
103+
ChannelStoreImpl._({
104104
required this.streams,
105105
required this.streamsByName,
106106
required this.subscriptions,

lib/model/internal_link.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:json_annotation/json_annotation.dart';
44
import '../api/model/narrow.dart';
55
import 'narrow.dart';
66
import 'store.dart';
7-
import 'stream.dart';
7+
import 'channel.dart';
88

99
part 'internal_link.g.dart';
1010

@@ -245,7 +245,7 @@ enum _NarrowOperator {
245245
///
246246
/// Returns null if the operand has an unexpected shape, or has the old shape
247247
/// (stream name but no ID) and we don't know of a stream by the given name.
248-
int? _parseStreamOperand(String operand, StreamStore store) {
248+
int? _parseStreamOperand(String operand, ChannelStore store) {
249249
// "New" (2018) format: ${stream_id}-${stream_name} .
250250
final match = RegExp(r'^(\d+)(?:-.*)?$').firstMatch(operand);
251251
final newFormatStreamId = (match != null) ? int.parse(match.group(1)!, radix: 10) : null;

lib/model/store.dart

+6-6
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import 'database.dart';
2323
import 'message.dart';
2424
import 'message_list.dart';
2525
import 'recent_dm_conversations.dart';
26-
import 'stream.dart';
26+
import 'channel.dart';
2727
import 'typing_status.dart';
2828
import 'unreads.dart';
2929

@@ -201,7 +201,7 @@ abstract class GlobalStore extends ChangeNotifier {
201201
/// This class does not attempt to poll an event queue
202202
/// to keep the data up to date. For that behavior, see
203203
/// [UpdateMachine].
204-
class PerAccountStore extends ChangeNotifier with StreamStore, MessageStore {
204+
class PerAccountStore extends ChangeNotifier with ChannelStore, MessageStore {
205205
/// Construct a store for the user's data, starting from the given snapshot.
206206
///
207207
/// The global store must already have been updated with
@@ -226,7 +226,7 @@ class PerAccountStore extends ChangeNotifier with StreamStore, MessageStore {
226226
connection ??= globalStore.apiConnectionFromAccount(account);
227227
assert(connection.zulipFeatureLevel == account.zulipFeatureLevel);
228228

229-
final streams = StreamStoreImpl(initialSnapshot: initialSnapshot);
229+
final streams = ChannelStoreImpl(initialSnapshot: initialSnapshot);
230230
return PerAccountStore._(
231231
globalStore: globalStore,
232232
connection: connection,
@@ -272,7 +272,7 @@ class PerAccountStore extends ChangeNotifier with StreamStore, MessageStore {
272272
required this.userSettings,
273273
required this.users,
274274
required this.typingStatus,
275-
required StreamStoreImpl streams,
275+
required ChannelStoreImpl streams,
276276
required MessageStoreImpl messages,
277277
required this.unreads,
278278
required this.recentDmConversationsView,
@@ -340,10 +340,10 @@ class PerAccountStore extends ChangeNotifier with StreamStore, MessageStore {
340340
UserTopicVisibilityPolicy topicVisibilityPolicy(int streamId, String topic) =>
341341
_streams.topicVisibilityPolicy(streamId, topic);
342342

343-
final StreamStoreImpl _streams;
343+
final ChannelStoreImpl _streams;
344344

345345
@visibleForTesting
346-
StreamStoreImpl get debugStreamStore => _streams;
346+
ChannelStoreImpl get debugStreamStore => _streams;
347347

348348
////////////////////////////////
349349
// Messages, and summaries of messages.

lib/model/unreads.dart

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import '../api/model/events.dart';
99
import '../log.dart';
1010
import 'algorithms.dart';
1111
import 'narrow.dart';
12-
import 'stream.dart';
12+
import 'channel.dart';
1313

1414
/// The view-model for unread messages.
1515
///
@@ -39,7 +39,7 @@ class Unreads extends ChangeNotifier {
3939
factory Unreads({
4040
required UnreadMessagesSnapshot initial,
4141
required int selfUserId,
42-
required StreamStore streamStore,
42+
required ChannelStore streamStore,
4343
}) {
4444
final streams = <int, Map<String, QueueList<int>>>{};
4545
final dms = <DmNarrow, QueueList<int>>{};
@@ -81,7 +81,7 @@ class Unreads extends ChangeNotifier {
8181
required this.selfUserId,
8282
});
8383

84-
final StreamStore streamStore;
84+
final ChannelStore streamStore;
8585

8686
// TODO excluded for now; would need to handle nuances around muting etc.
8787
// int count;
@@ -145,7 +145,7 @@ class Unreads extends ChangeNotifier {
145145
}
146146

147147
/// The "strict" unread count for this stream,
148-
/// using [StreamStore.isTopicVisible].
148+
/// using [ChannelStore.isTopicVisible].
149149
///
150150
/// If the stream is muted, this will count only topics that are
151151
/// actively unmuted.
@@ -166,7 +166,7 @@ class Unreads extends ChangeNotifier {
166166
}
167167

168168
/// The "broad" unread count for this stream,
169-
/// using [StreamStore.isTopicVisibleInStream].
169+
/// using [ChannelStore.isTopicVisibleInStream].
170170
///
171171
/// This includes topics that have no visibility policy of their own,
172172
/// even if the stream itself is muted.

test/model/stream_test.dart renamed to test/model/channel_test.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'package:zulip/api/model/events.dart';
55
import 'package:zulip/api/model/initial_snapshot.dart';
66
import 'package:zulip/api/model/model.dart';
77
import 'package:zulip/model/store.dart';
8-
import 'package:zulip/model/stream.dart';
8+
import 'package:zulip/model/channel.dart';
99

1010
import '../example_data.dart' as eg;
1111
import 'test_store.dart';
@@ -14,7 +14,7 @@ void main() {
1414
group('Unified stream/sub data', () {
1515
/// Check that `streams`, `streamsByName`, and `subscriptions` all agree
1616
/// and point to the same objects where applicable.
17-
void checkUnified(StreamStore store) {
17+
void checkUnified(ChannelStore store) {
1818
check(store.streamsByName).length.equals(store.streams.length);
1919
for (final MapEntry(key: streamId, value: stream)
2020
in store.streams.entries) {

test/model/store_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void main() {
163163
});
164164

165165
group('PerAccountStore.handleEvent', () {
166-
// Mostly this method just dispatches to StreamStore and MessageStore etc.,
166+
// Mostly this method just dispatches to ChannelStore and MessageStore etc.,
167167
// and so most of the tests live in the test files for those
168168
// (but they call the handleEvent method because it's the entry point).
169169

test/model/unreads_test.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ void main() {
1616
// These variables are the common state operated on by each test.
1717
// Each test case calls [prepare] to initialize them.
1818
late Unreads model;
19-
late PerAccountStore streamStore; // TODO reduce this to StreamStore
19+
late PerAccountStore streamStore; // TODO reduce this to ChannelStore
2020
late int notifiedCount;
2121

2222
void checkNotified({required int count}) {

0 commit comments

Comments
 (0)