diff --git a/lib/model/autocomplete.dart b/lib/model/autocomplete.dart index fafe7330ab..3b28b21f7a 100644 --- a/lib/model/autocomplete.dart +++ b/lib/model/autocomplete.dart @@ -1344,7 +1344,7 @@ class ChannelLinkAutocompleteView extends AutocompleteView get streams; + Map get channels; - /// All known channels/streams, indexed by [ZulipStream.name]. + /// All known channels, indexed by [ZulipStream.name]. /// - /// The same [ZulipStream] objects also appear in [streams]. + /// The same [ZulipStream] objects also appear in [channels]. /// /// For channels the self-user is subscribed to, the value is in fact /// a [Subscription] object and also appears in [subscriptions]. - Map get streamsByName; + Map get channelsByName; /// All the channels the self-user is subscribed to, indexed by /// [Subscription.streamId], with subscription details. /// - /// The same [Subscription] objects are among the values in [streams] - /// and [streamsByName]. + /// The same [Subscription] objects are among the values in [channels] + /// and [channelsByName]. Map get subscriptions; /// All the channel folders, including archived ones, indexed by ID. @@ -168,7 +168,7 @@ mixin ChannelStore on UserStore { /// The channel folder of [channelId], /// including the "PINNED" or "OTHER" pseudo-channels (e.g. for the inbox). UiChannelFolder uiChannelFolder(int channelId) => - switch (streams[channelId]) { + switch (channels[channelId]) { Subscription(:final pinToTop) when pinToTop => UiChannelFolderPseudoPinned(), ZulipStream(:final folderId) when folderId != null => @@ -377,10 +377,10 @@ mixin ProxyChannelStore on ChannelStore { ChannelStore get channelStore; @override - Map get streams => channelStore.streams; + Map get channels => channelStore.channels; @override - Map get streamsByName => channelStore.streamsByName; + Map get channelsByName => channelStore.channelsByName; @override Map get subscriptions => channelStore.subscriptions; @@ -422,9 +422,9 @@ class ChannelStoreImpl extends HasUserStore with ChannelStore { final subscriptions = Map.fromEntries(initialSnapshot.subscriptions.map( (subscription) => MapEntry(subscription.streamId, subscription))); - final streams = Map.of(subscriptions); + final channels = Map.of(subscriptions); for (final stream in initialSnapshot.streams) { - streams.putIfAbsent(stream.streamId, () => stream); + channels.putIfAbsent(stream.streamId, () => stream); } final channelFolders = Map.fromEntries((initialSnapshot.channelFolders ?? []) @@ -442,8 +442,8 @@ class ChannelStoreImpl extends HasUserStore with ChannelStore { return ChannelStoreImpl._( users: users, - streams: streams, - streamsByName: streams.map((_, stream) => MapEntry(stream.name, stream)), + channels: channels, + channelsByName: channels.map((_, channel) => MapEntry(channel.name, channel)), subscriptions: subscriptions, channelFolders: channelFolders, topicVisibility: topicVisibility, @@ -452,17 +452,17 @@ class ChannelStoreImpl extends HasUserStore with ChannelStore { ChannelStoreImpl._({ required super.users, - required this.streams, - required this.streamsByName, + required this.channels, + required this.channelsByName, required this.subscriptions, required this.channelFolders, required this.topicVisibility, }); @override - final Map streams; + final Map channels; @override - final Map streamsByName; + final Map channelsByName; @override final Map subscriptions; @override @@ -490,27 +490,27 @@ class ChannelStoreImpl extends HasUserStore with ChannelStore { switch (event) { case ChannelCreateEvent(): assert(event.streams.every((stream) => - !streams.containsKey(stream.streamId) - && !streamsByName.containsKey(stream.name))); - streams.addEntries(event.streams.map((stream) => MapEntry(stream.streamId, stream))); - streamsByName.addEntries(event.streams.map((stream) => MapEntry(stream.name, stream))); + !channels.containsKey(stream.streamId) + && !channelsByName.containsKey(stream.name))); + channels.addEntries(event.streams.map((stream) => MapEntry(stream.streamId, stream))); + channelsByName.addEntries(event.streams.map((stream) => MapEntry(stream.name, stream))); // (Don't touch `subscriptions`. If the user is subscribed to the stream, // details will come in a later `subscription` event.) case ChannelDeleteEvent(): for (final channelId in event.channelIds) { - final channel = streams.remove(channelId); + final channel = channels.remove(channelId); if (channel == null) continue; // TODO(log) assert(channelId == channel.streamId); - assert(identical(channel, streamsByName[channel.name])); + assert(identical(channel, channelsByName[channel.name])); assert(subscriptions[channelId] == null || identical(subscriptions[channelId], channel)); - streamsByName.remove(channel.name); + channelsByName.remove(channel.name); subscriptions.remove(channelId); } case ChannelUpdateEvent(): - final stream = streams[event.streamId]; + final stream = channels[event.streamId]; if (stream == null) return; // TODO(log) assert(stream.streamId == event.streamId); @@ -532,10 +532,10 @@ class ChannelStoreImpl extends HasUserStore with ChannelStore { case ChannelPropertyName.name: final streamName = stream.name; assert(streamName == event.name); - assert(identical(streams[stream.streamId], streamsByName[streamName])); + assert(identical(channels[stream.streamId], channelsByName[streamName])); stream.name = event.value as String; - streamsByName.remove(streamName); - streamsByName[stream.name] = stream; + channelsByName.remove(streamName); + channelsByName[stream.name] = stream; case ChannelPropertyName.isArchived: stream.isArchived = event.value as bool; case ChannelPropertyName.description: @@ -572,35 +572,35 @@ class ChannelStoreImpl extends HasUserStore with ChannelStore { switch (event) { case SubscriptionAddEvent(): for (final subscription in event.subscriptions) { - assert(streams.containsKey(subscription.streamId)); - assert(streams[subscription.streamId] is! Subscription); - assert(streamsByName.containsKey(subscription.name)); - assert(streamsByName[subscription.name] is! Subscription); + assert(channels.containsKey(subscription.streamId)); + assert(channels[subscription.streamId] is! Subscription); + assert(channelsByName.containsKey(subscription.name)); + assert(channelsByName[subscription.name] is! Subscription); assert(!subscriptions.containsKey(subscription.streamId)); - streams[subscription.streamId] = subscription; - streamsByName[subscription.name] = subscription; + channels[subscription.streamId] = subscription; + channelsByName[subscription.name] = subscription; subscriptions[subscription.streamId] = subscription; } case SubscriptionRemoveEvent(): for (final channelId in event.channelIds) { - assert(streams.containsKey(channelId)); - assert(streams[channelId] is Subscription); - assert(streamsByName.containsKey(streams[channelId]!.name)); - assert(streamsByName[streams[channelId]!.name] is Subscription); + assert(channels.containsKey(channelId)); + assert(channels[channelId] is Subscription); + assert(channelsByName.containsKey(channels[channelId]!.name)); + assert(channelsByName[channels[channelId]!.name] is Subscription); assert(subscriptions.containsKey(channelId)); final subscription = subscriptions.remove(channelId); if (subscription == null) continue; // TODO(log) final stream = ZulipStream.fromSubscription(subscription); - streams[channelId] = stream; - streamsByName[subscription.name] = stream; + channels[channelId] = stream; + channelsByName[subscription.name] = stream; } case SubscriptionUpdateEvent(): final subscription = subscriptions[event.channelId]; if (subscription == null) return; // TODO(log) - assert(identical(streams[event.channelId], subscription)); - assert(identical(streamsByName[subscription.name], subscription)); + assert(identical(channels[event.channelId], subscription)); + assert(identical(channelsByName[subscription.name], subscription)); switch (event.property) { case SubscriptionProperty.color: subscription.color = event.value as int; diff --git a/lib/model/internal_link.dart b/lib/model/internal_link.dart index 4f40b5e063..ae6681abde 100644 --- a/lib/model/internal_link.dart +++ b/lib/model/internal_link.dart @@ -85,7 +85,7 @@ String narrowLinkFragment(PerAccountStore store, Narrow narrow, {int? nearMessag switch (element) { case ApiNarrowChannel(): final channelId = element.operand; - final name = store.streams[channelId]?.name ?? 'unknown'; + final name = store.channels[channelId]?.name ?? 'unknown'; final slugifiedName = _encodeHashComponent(name.replaceAll(' ', '-')); fragment.write('$channelId-$slugifiedName'); case ApiNarrowTopic(): @@ -380,7 +380,7 @@ int? _parseStreamOperand(String operand, ChannelStore store) { // "New" (2018) format: ${stream_id}-${stream_name} . final match = RegExp(r'^(\d+)(?:-.*)?$').firstMatch(operand); final newFormatStreamId = (match != null) ? int.parse(match.group(1)!, radix: 10) : null; - if (newFormatStreamId != null && store.streams.containsKey(newFormatStreamId)) { + if (newFormatStreamId != null && store.channels.containsKey(newFormatStreamId)) { return newFormatStreamId; } @@ -388,8 +388,8 @@ int? _parseStreamOperand(String operand, ChannelStore store) { // so that links in old conversations continue to work. final String? streamName = decodeHashComponent(operand); if (streamName == null) return null; - final stream = store.streamsByName[streamName]; - if (stream != null) return stream.streamId; + final channel = store.channelsByName[streamName]; + if (channel != null) return channel.streamId; if (newFormatStreamId != null) { // Neither format found a stream, so it's hidden or doesn't exist. But diff --git a/lib/model/message.dart b/lib/model/message.dart index 17d4775fbc..28a42dbb9d 100644 --- a/lib/model/message.dart +++ b/lib/model/message.dart @@ -105,7 +105,7 @@ mixin MessageStore on ChannelStore { final ZulipStream? channel; if (message is StreamMessage) { - channel = streams[message.streamId]; + channel = channels[message.streamId]; if (channel == null) { assert(false); // TODO(log) return true; diff --git a/lib/widgets/action_sheet.dart b/lib/widgets/action_sheet.dart index 5b38935071..7c3d3ee629 100644 --- a/lib/widgets/action_sheet.dart +++ b/lib/widgets/action_sheet.dart @@ -500,7 +500,7 @@ void showChannelActionSheet(BuildContext context, { && messageListPageNarrow.channelId == channelId; final unreadCount = store.unreads.countInChannelNarrow(channelId); - final channel = store.streams[channelId]; + final channel = store.channels[channelId]; final isSubscribed = channel is Subscription; final buttonSections = [ if (!isSubscribed diff --git a/lib/widgets/actions.dart b/lib/widgets/actions.dart index d92dbad306..cb1ec12cb5 100644 --- a/lib/widgets/actions.dart +++ b/lib/widgets/actions.dart @@ -315,7 +315,7 @@ abstract final class ZulipAction { required int channelId, }) async { final store = PerAccountStoreWidget.of(context); - final channel = store.streams[channelId]; + final channel = store.channels[channelId]; if (channel == null || channel is Subscription) return; // TODO could give feedback try { diff --git a/lib/widgets/all_channels.dart b/lib/widgets/all_channels.dart index c6a765a11e..3f43ddfff8 100644 --- a/lib/widgets/all_channels.dart +++ b/lib/widgets/all_channels.dart @@ -52,7 +52,7 @@ class AllChannelsPageBody extends StatelessWidget { @override Widget build(BuildContext context) { final zulipLocalizations = ZulipLocalizations.of(context); - final channels = PerAccountStoreWidget.of(context).streams; + final channels = PerAccountStoreWidget.of(context).channels; if (channels.isEmpty) { return PageBodyEmptyContentPlaceholder( diff --git a/lib/widgets/autocomplete.dart b/lib/widgets/autocomplete.dart index 7b5284ef43..752cec1937 100644 --- a/lib/widgets/autocomplete.dart +++ b/lib/widgets/autocomplete.dart @@ -230,7 +230,7 @@ class ComposeAutocomplete extends AutocompleteField { final store = PerAccountStoreWidget.of(context); final zulipLocalizations = ZulipLocalizations.of(context); - final channelName = store.streams[widget.narrow.channelId]?.name + final channelName = store.channels[widget.narrow.channelId]?.name ?? zulipLocalizations.unknownChannelName; final hintTopic = _hintTopic(); final hintDestination = hintTopic == null @@ -891,7 +891,7 @@ class _FixedDestinationContentInput extends StatelessWidget { switch (narrow) { case TopicNarrow(:final channelId, :final topic): final store = PerAccountStoreWidget.of(context); - final channelName = store.streams[channelId]?.name + final channelName = store.channels[channelId]?.name ?? zulipLocalizations.unknownChannelName; return zulipLocalizations.composeBoxChannelContentHint( // No i18n of this use of "#" and ">" string; those are part of how @@ -2251,7 +2251,7 @@ class _ComposeBoxState extends State with PerAccountStoreAwareStateM switch (widget.narrow) { case ChannelNarrow(:final channelId): case TopicNarrow(:final channelId): - final channel = store.streams[channelId]; + final channel = store.channels[channelId]; if (channel == null || !store.selfHasContentAccess(channel)) { return _Banner( intent: _BannerIntent.info, @@ -2323,7 +2323,7 @@ class _ComposeBoxState extends State with PerAccountStoreAwareStateM switch (narrow) { case ChannelNarrow(:final channelId): case TopicNarrow(:final channelId): - final channel = store.streams[channelId]; + final channel = store.channels[channelId]; // (If the channel is unknown, we should have already decided // what to show.) assert(channel != null); diff --git a/lib/widgets/message_list.dart b/lib/widgets/message_list.dart index 61a21d3f92..f585fa7e44 100644 --- a/lib/widgets/message_list.dart +++ b/lib/widgets/message_list.dart @@ -581,8 +581,8 @@ class MessageListAppBarTitle extends StatelessWidget { final Narrow narrow; final bool willCenterTitle; - Widget _buildStreamRow(BuildContext context, { - ZulipStream? stream, + Widget _buildChannelRow(BuildContext context, { + ZulipStream? channel, }) { final store = PerAccountStoreWidget.of(context); final zulipLocalizations = ZulipLocalizations.of(context); @@ -590,9 +590,9 @@ class MessageListAppBarTitle extends StatelessWidget { // A null [Icon.icon] makes a blank space. IconData? icon; Color? iconColor; - if (stream != null) { - icon = iconDataForStream(stream); - iconColor = colorSwatchFor(context, store.subscriptions[stream.streamId]) + if (channel != null) { + icon = iconDataForStream(channel); + iconColor = colorSwatchFor(context, store.subscriptions[channel.streamId]) .iconOnBarBackground; } @@ -606,19 +606,19 @@ class MessageListAppBarTitle extends StatelessWidget { Icon(size: 16, color: iconColor, icon), const SizedBox(width: 4), Flexible(child: Text( - stream?.name ?? zulipLocalizations.unknownChannelName)), + channel?.name ?? zulipLocalizations.unknownChannelName)), ]); } Widget _buildTopicRow(BuildContext context, { - required ZulipStream? stream, + required ZulipStream? channel, required TopicName topic, }) { final store = PerAccountStoreWidget.of(context); final designVariables = DesignVariables.of(context); - final icon = stream == null ? null + final icon = channel == null ? null : iconDataForTopicVisibilityPolicy( - store.topicVisibilityPolicy(stream.streamId, topic)); + store.topicVisibilityPolicy(channel.streamId, topic)); return Row( mainAxisSize: MainAxisSize.min, children: [ @@ -650,7 +650,7 @@ class MessageListAppBarTitle extends StatelessWidget { case ChannelNarrow(:var channelId): final store = PerAccountStoreWidget.of(context); - final stream = store.streams[channelId]; + final channel = store.channels[channelId]; final alignment = willCenterTitle ? Alignment.center : AlignmentDirectional.centerStart; @@ -662,11 +662,11 @@ class MessageListAppBarTitle extends StatelessWidget { showChannelActionSheet(context, channelId: channelId); }, child: Align(alignment: alignment, - child: _buildStreamRow(context, stream: stream)))); + child: _buildChannelRow(context, channel: channel)))); case TopicNarrow(:var channelId, :var topic): final store = PerAccountStoreWidget.of(context); - final stream = store.streams[channelId]; + final channel = store.channels[channelId]; final alignment = willCenterTitle ? Alignment.center : AlignmentDirectional.centerStart; @@ -679,7 +679,7 @@ class MessageListAppBarTitle extends StatelessWidget { showChannelActionSheet(context, channelId: channelId); }, child: Align(alignment: alignment, - child: _buildStreamRow(context, stream: stream))), + child: _buildChannelRow(context, channel: channel))), GestureDetector( behavior: HitTestBehavior.translucent, onLongPress: () { @@ -697,7 +697,7 @@ class MessageListAppBarTitle extends StatelessWidget { someMessageIdInTopic: someMessage?.id); }, child: Align(alignment: alignment, - child: _buildTopicRow(context, stream: stream, topic: topic))), + child: _buildTopicRow(context, channel: channel, topic: topic))), ]); case DmNarrow(:var otherRecipientIds): @@ -1315,7 +1315,7 @@ class _EmptyMessageListPlaceholder extends StatelessWidget { header: zulipLocalizations.emptyMessageListCombinedFeed); case ChannelNarrow(:final channelId) || TopicNarrow(:final channelId): - final channel = store.streams[channelId]; + final channel = store.channels[channelId]; if (channel == null) { return PageBodyEmptyContentPlaceholder( header: zulipLocalizations.emptyMessageListChannelUnavailable); @@ -1848,16 +1848,16 @@ class StreamMessageRecipientHeader extends StatelessWidget { final backgroundColor = swatch.barBackground; final iconColor = swatch.iconOnBarBackground; - final Widget streamWidget; + final Widget channelWidget; if (!_containsDifferentChannels(narrow)) { - streamWidget = const SizedBox(width: 16); + channelWidget = const SizedBox(width: 16); } else { - final stream = store.streams[streamId]; - final streamName = stream?.name + final channel = store.channels[streamId]; + final channelName = channel?.name ?? message.conversation.displayRecipient ?? zulipLocalizations.unknownChannelName; // TODO(log) - streamWidget = GestureDetector( + channelWidget = GestureDetector( behavior: HitTestBehavior.opaque, onTap: () => Navigator.push(context, MessageListPage.buildRoute(context: context, @@ -1875,10 +1875,10 @@ class StreamMessageRecipientHeader extends StatelessWidget { padding: const EdgeInsets.only(left: 6, right: 6, bottom: 3), child: Icon(size: 16, color: iconColor, // A null [Icon.icon] makes a blank space. - stream != null ? iconDataForStream(stream) : null)), + channel != null ? iconDataForStream(channel) : null)), Padding( padding: const EdgeInsets.symmetric(vertical: 11), - child: Text(streamName, + child: Text(channelName, style: recipientHeaderTextStyle(context), overflow: TextOverflow.ellipsis), ), @@ -1930,7 +1930,7 @@ class StreamMessageRecipientHeader extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.center, children: [ // TODO(#282): Long stream name will break layout; find a fix. - streamWidget, + channelWidget, Expanded(child: topicWidget), // TODO topic links? // Then web also has edit/resolve/mute buttons. Skip those for mobile. diff --git a/lib/widgets/text.dart b/lib/widgets/text.dart index 10a6485023..37ebb23741 100644 --- a/lib/widgets/text.dart +++ b/lib/widgets/text.dart @@ -658,7 +658,7 @@ InlineSpan channelTopicLabelSpan({ }) { final zulipLocalizations = ZulipLocalizations.of(context); final store = PerAccountStoreWidget.of(context); - final channel = store.streams[channelId]; + final channel = store.channels[channelId]; final subscription = store.subscriptions[channelId]; final swatch = colorSwatchFor(context, subscription); final channelIcon = channel != null ? iconDataForStream(channel) : null; diff --git a/lib/widgets/topic_list.dart b/lib/widgets/topic_list.dart index f77e7c065a..1838eb93ea 100644 --- a/lib/widgets/topic_list.dart +++ b/lib/widgets/topic_list.dart @@ -65,17 +65,17 @@ class _TopicListAppBarTitle extends StatelessWidget { final int channelId; final bool willCenterTitle; - Widget _buildStreamRow(BuildContext context) { + Widget _buildChannelRow(BuildContext context) { // TODO(#1039) implement a consistent app bar design here final zulipLocalizations = ZulipLocalizations.of(context); final designVariables = DesignVariables.of(context); final store = PerAccountStoreWidget.of(context); - final stream = store.streams[channelId]; + final channel = store.channels[channelId]; final channelIconColor = colorSwatchFor(context, store.subscriptions[channelId]).iconOnBarBackground; // A null [Icon.icon] makes a blank space. - final icon = stream != null ? iconDataForStream(stream) : null; + final icon = channel != null ? iconDataForStream(channel) : null; return Row( mainAxisSize: MainAxisSize.min, // TODO(design): The vertical alignment of the stream privacy icon is a bit ad hoc. @@ -86,7 +86,7 @@ class _TopicListAppBarTitle extends StatelessWidget { Padding(padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 6), child: Icon(size: 18, icon, color: channelIconColor)), Flexible(child: Text( - stream?.name ?? zulipLocalizations.unknownChannelName, + channel?.name ?? zulipLocalizations.unknownChannelName, style: TextStyle( fontSize: 20, height: 30 / 20, @@ -111,7 +111,7 @@ class _TopicListAppBarTitle extends StatelessWidget { showTopicListButton: false); }, child: Align(alignment: alignment, - child: _buildStreamRow(context)))); + child: _buildChannelRow(context)))); } } diff --git a/test/model/channel_test.dart b/test/model/channel_test.dart index 6bff7b0102..3613089cc9 100644 --- a/test/model/channel_test.dart +++ b/test/model/channel_test.dart @@ -17,14 +17,14 @@ void main() { TestZulipBinding.ensureInitialized(); group('Unified stream/sub data', () { - /// Check that `streams`, `streamsByName`, and `subscriptions` all agree + /// Check that `channels`, `channelsByName`, and `subscriptions` all agree /// and point to the same objects where applicable. void checkUnified(ChannelStore store) { - check(store.streamsByName).length.equals(store.streams.length); + check(store.channelsByName).length.equals(store.channels.length); for (final MapEntry(key: streamId, value: stream) - in store.streams.entries) { + in store.channels.entries) { check(streamId).equals(stream.streamId); - check(store.streamsByName[stream.name]).identicalTo(stream); + check(store.channelsByName[stream.name]).identicalTo(stream); if (stream is Subscription) { check(store.subscriptions[streamId]).identicalTo(stream); } else { @@ -34,7 +34,7 @@ void main() { for (final MapEntry(key: streamId, value: subscription) in store.subscriptions.entries) { check(streamId).equals(subscription.streamId); - check(store.streams[streamId]).identicalTo(subscription); + check(store.channels[streamId]).identicalTo(subscription); } } @@ -62,12 +62,12 @@ void main() { await store.addSubscription(eg.subscription(stream1)); checkUnified(store); - await store.handleEvent(eg.channelUpdateEvent(store.streams[stream1.streamId]!, + await store.handleEvent(eg.channelUpdateEvent(store.channels[stream1.streamId]!, property: ChannelPropertyName.name, value: 'new stream', )); checkUnified(store); - await store.handleEvent(eg.channelUpdateEvent(store.streams[stream1.streamId]!, + await store.handleEvent(eg.channelUpdateEvent(store.channels[stream1.streamId]!, property: ChannelPropertyName.channelPostPolicy, value: ChannelPostPolicy.administrators, )); diff --git a/test/model/store_checks.dart b/test/model/store_checks.dart index fd978a468d..6050a9f8f8 100644 --- a/test/model/store_checks.dart +++ b/test/model/store_checks.dart @@ -74,8 +74,8 @@ extension PerAccountStoreChecks on Subject { Subject get selfUserId => has((x) => x.selfUserId, 'selfUserId'); Subject get userSettings => has((x) => x.userSettings, 'userSettings'); Subject> get savedSnippets => has((x) => x.savedSnippets, 'savedSnippets'); - Subject> get streams => has((x) => x.streams, 'streams'); - Subject> get streamsByName => has((x) => x.streamsByName, 'streamsByName'); + Subject> get channels => has((x) => x.channels, 'channels'); + Subject> get channelsByName => has((x) => x.channelsByName, 'channelsByName'); Subject> get subscriptions => has((x) => x.subscriptions, 'subscriptions'); Subject> get messages => has((x) => x.messages, 'messages'); Subject> get starredMessages => has((x) => x.starredMessages, 'starredMessages'); diff --git a/test/model/store_test.dart b/test/model/store_test.dart index 491710e322..f658169266 100644 --- a/test/model/store_test.dart +++ b/test/model/store_test.dart @@ -947,7 +947,7 @@ void main() { await store.addStream(stream); // Set up a situation that breaks our data structures' invariants: // a stream/channel found in the by-ID map is missing in the by-name map. - store.streamsByName.remove(stream.name); + store.channelsByName.remove(stream.name); // Then prepare an event on which handleEvent will throw // because it hits that broken invariant. connection.prepare(json: GetEventsResult(events: [ diff --git a/test/model/unreads_test.dart b/test/model/unreads_test.dart index 1d52613115..14d70b6802 100644 --- a/test/model/unreads_test.dart +++ b/test/model/unreads_test.dart @@ -794,7 +794,7 @@ void main() { fillWithMessages(unreadMessages); final unknownChannel = eg.stream(); - assert(!store.streams.containsKey(unknownChannel.streamId)); + assert(!store.channels.containsKey(unknownChannel.streamId)); final unknownUnreadMessage = eg.streamMessage( stream: unknownChannel, topic: origTopic); diff --git a/test/widgets/action_sheet_test.dart b/test/widgets/action_sheet_test.dart index 1953c84812..1a1a355104 100644 --- a/test/widgets/action_sheet_test.dart +++ b/test/widgets/action_sheet_test.dart @@ -278,7 +278,7 @@ void main() { child: TopicListPage(channelId: channelId))); await tester.pump(); - final titleText = store.streams[channelId]?.name ?? '(unknown channel)'; + final titleText = store.channels[channelId]?.name ?? '(unknown channel)'; await tester.longPress(find.descendant( of: find.byType(ZulipAppBar), matching: find.text(titleText))); @@ -314,7 +314,7 @@ void main() { testWidgets('public channel', (tester) async { await prepare(); - check(store.streams[someChannel.streamId]).isNotNull() + check(store.channels[someChannel.streamId]).isNotNull() ..inviteOnly.isFalse()..isWebPublic.isFalse(); await showFromInbox(tester); check(findInHeader(find.byIcon(ZulipIcons.hash_sign))).findsOne(); @@ -331,7 +331,7 @@ void main() { // modern servers actually do that or if they still use this // separate field.) isWebPublic: true)); - check(store.streams[someChannel.streamId]).isNotNull() + check(store.channels[someChannel.streamId]).isNotNull() ..inviteOnly.isFalse()..isWebPublic.isTrue(); await showFromInbox(tester); check(findInHeader(find.byIcon(ZulipIcons.globe))).findsOne(); @@ -342,7 +342,7 @@ void main() { await prepare(); await store.handleEvent(eg.channelUpdateEvent(someChannel, property: ChannelPropertyName.inviteOnly, value: true)); - check(store.streams[someChannel.streamId]).isNotNull() + check(store.channels[someChannel.streamId]).isNotNull() ..inviteOnly.isTrue()..isWebPublic.isFalse(); await showFromInbox(tester); check(findInHeader(find.byIcon(ZulipIcons.lock))).findsOne(); @@ -353,7 +353,7 @@ void main() { await prepare(); await store.handleEvent(ChannelDeleteEvent(id: 1, channelIds: [someChannel.streamId])); - check(store.streams[someChannel.streamId]).isNull(); + check(store.channels[someChannel.streamId]).isNull(); await showFromTopicListAppBar(tester); check(findInHeader(find.byType(Icon))).findsNothing(); check(findInHeader(find.textContaining('(unknown channel)'))).findsOne(); @@ -927,7 +927,7 @@ void main() { testWidgets('with topic', (tester) async { await prepare(); - check(store.streams[someChannel.streamId]).isNotNull() + check(store.channels[someChannel.streamId]).isNotNull() ..inviteOnly.isFalse()..isWebPublic.isFalse(); await showFromAppBar(tester); check(findInHeader(find.byIcon(ZulipIcons.hash_sign))).findsOne(); @@ -937,7 +937,7 @@ void main() { testWidgets('without topic (general chat)', (tester) async { await prepare(topic: ''); - check(store.streams[someChannel.streamId]).isNotNull() + check(store.channels[someChannel.streamId]).isNotNull() ..inviteOnly.isFalse()..isWebPublic.isFalse(); final message = eg.streamMessage( stream: someChannel, topic: '', sender: eg.otherUser); diff --git a/test/widgets/all_channels_test.dart b/test/widgets/all_channels_test.dart index f6e1092781..241fae7a61 100644 --- a/test/widgets/all_channels_test.dart +++ b/test/widgets/all_channels_test.dart @@ -159,7 +159,7 @@ void main() { channels: [channel1, channel2, channel3, channel4, channel5, channel6]); final channel7 = await addPrivateChannelWithContentAccess('d'); - check(store.streams.length).equals(7); + check(store.channels.length).equals(7); await tester.pump(); final channelsInUiOrder = diff --git a/test/widgets/compose_box_test.dart b/test/widgets/compose_box_test.dart index 7599fb5cb7..0a3dfab4e7 100644 --- a/test/widgets/compose_box_test.dart +++ b/test/widgets/compose_box_test.dart @@ -1819,7 +1819,7 @@ void main() { // new store has the same boring data, in order to present a compose box // that allows composing, instead of a no-posting-permission banner ..accountId.equals(store.accountId) - ..streams.containsKey(channel.streamId); + ..channels.containsKey(channel.streamId); checkContentInputValue(tester, 'some content'); });