Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions lib/api/model/events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -616,9 +616,21 @@ class ChannelDeleteEvent extends ChannelEvent {
@JsonKey(includeToJson: true)
String get op => 'delete';

final List<ZulipStream> streams;
@JsonKey(name: 'stream_ids', readValue: _readChannelIds)
final List<int> channelIds;

// TODO(server-10) simplify away; rely on stream_ids
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api: Update ChannelDeleteEvent to match new API changes

Let's link to #api design > stream deletion events @ 💬 in the commit message.

(Also a nit: the symptom is described in that discussion; it's noticeable but it's not as bad as crashing the app.)

static List<int> _readChannelIds(Map<dynamic, dynamic> json, String key) {
final channelIds = json['stream_ids'] as List<dynamic>?;
if (channelIds != null) return channelIds.map((id) => id as int).toList();

final channels = json['streams'] as List<dynamic>;
return channels
.map((c) => (c as Map<String, dynamic>)['stream_id'] as int)
.toList();
}

ChannelDeleteEvent({required super.id, required this.streams});
ChannelDeleteEvent({required super.id, required this.channelIds});

factory ChannelDeleteEvent.fromJson(Map<String, dynamic> json) =>
_$ChannelDeleteEventFromJson(json);
Expand Down Expand Up @@ -691,6 +703,8 @@ class ChannelUpdateEvent extends ChannelEvent {
case ChannelPropertyName.canSendMessageGroup:
case ChannelPropertyName.canSubscribeGroup:
return GroupSettingValue.fromJson(value);
case ChannelPropertyName.isRecentlyActive:
return value as bool?;
case ChannelPropertyName.streamWeeklyTraffic:
return value as int?;
case null:
Expand Down
11 changes: 7 additions & 4 deletions lib/api/model/events.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions lib/api/model/initial_snapshot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class InitialSnapshot {

final List<CustomProfileField> customProfileFields;

@JsonKey(name: 'max_stream_name_length')
final int maxChannelNameLength;
final int maxTopicLength;

final int serverPresencePingIntervalSeconds;
Expand Down Expand Up @@ -160,6 +162,7 @@ class InitialSnapshot {
required this.zulipMergeBase,
required this.alertWords,
required this.customProfileFields,
required this.maxChannelNameLength,
required this.maxTopicLength,
required this.serverPresencePingIntervalSeconds,
required this.serverPresenceOfflineThresholdSeconds,
Expand Down
2 changes: 2 additions & 0 deletions lib/api/model/initial_snapshot.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions lib/api/model/model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ class ZulipStream {
GroupSettingValue? canSendMessageGroup; // TODO(server-10)
GroupSettingValue? canSubscribeGroup; // TODO(server-10)

bool? isRecentlyActive; // TODO(server-10)
// TODO(server-8): added in FL 199, was previously only on [Subscription] objects
int? streamWeeklyTraffic;

Expand All @@ -691,6 +692,7 @@ class ZulipStream {
required this.canDeleteOwnMessageGroup,
required this.canSendMessageGroup,
required this.canSubscribeGroup,
required this.isRecentlyActive,
required this.streamWeeklyTraffic,
});

Expand All @@ -715,6 +717,7 @@ class ZulipStream {
canDeleteOwnMessageGroup: subscription.canDeleteOwnMessageGroup,
canSendMessageGroup: subscription.canSendMessageGroup,
canSubscribeGroup: subscription.canSubscribeGroup,
isRecentlyActive: subscription.isRecentlyActive,
streamWeeklyTraffic: subscription.streamWeeklyTraffic,
);
}
Expand Down Expand Up @@ -752,6 +755,7 @@ enum ChannelPropertyName {
canDeleteOwnMessageGroup,
canSendMessageGroup,
canSubscribeGroup,
isRecentlyActive,
streamWeeklyTraffic;

/// Get a [ChannelPropertyName] from a raw, snake-case string we recognize, else null.
Expand Down Expand Up @@ -837,6 +841,7 @@ class Subscription extends ZulipStream {
required super.canDeleteOwnMessageGroup,
required super.canSendMessageGroup,
required super.canSubscribeGroup,
required super.isRecentlyActive,
required super.streamWeeklyTraffic,
required this.desktopNotifications,
required this.emailNotifications,
Expand Down
5 changes: 5 additions & 0 deletions lib/api/model/model.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading