Skip to content

Commit 89f3b78

Browse files
committed
api [nfc]: Change Subscription to extend from ZulipStream
1 parent f0d11a9 commit 89f3b78

File tree

2 files changed

+25
-56
lines changed

2 files changed

+25
-56
lines changed

lib/api/model/model.dart

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -312,80 +312,49 @@ enum StreamPostPolicy {
312312
/// For docs, search for "subscriptions:"
313313
/// in <https://zulip.com/api/register-queue>.
314314
@JsonSerializable(fieldRename: FieldRename.snake)
315-
class Subscription {
316-
// First, fields that are about the stream and not the user's relation to it.
317-
// These are largely the same as in [ZulipStream].
318-
319-
final int streamId;
320-
final String name;
321-
final String description;
322-
final String renderedDescription;
323-
324-
final int dateCreated;
325-
final int? firstMessageId;
326-
final int? streamWeeklyTraffic;
327-
328-
final bool inviteOnly;
329-
final bool isWebPublic;
330-
final bool historyPublicToSubscribers;
331-
final int? messageRetentionDays;
315+
class Subscription extends ZulipStream {
332316
// final List<int> subscribers; // we register with includeSubscribers false
333317

334-
final StreamPostPolicy streamPostPolicy;
335-
// final bool? isAnnouncementOnly; // deprecated for `streamPostPolicy`; ignore
336-
337-
// TODO(server-6): `canRemoveSubscribersGroupId` added in FL 142
338-
// TODO(server-8): in FL 197 renamed to `canRemoveSubscribersGroup`
339-
@JsonKey(readValue: _readCanRemoveSubscribersGroup)
340-
final int? canRemoveSubscribersGroup;
341-
342-
// Then, fields that are specific to the subscription,
343-
// i.e. the user's relationship to the stream.
344-
345318
final bool? desktopNotifications;
346319
final bool? emailNotifications;
347320
final bool? wildcardMentionsNotify;
348321
final bool? pushNotifications;
349322
final bool? audibleNotifications;
350323

351324
final bool pinToTop;
352-
353325
final bool isMuted;
354326
// final bool? inHomeView; // deprecated; ignore
355327

356328
final String color;
357329

358-
static int? _readCanRemoveSubscribersGroup(Map json, String key) {
359-
return json[key] ?? json['can_remove_subscribers_group_id'];
360-
}
361-
362330
Subscription({
363-
required this.streamId,
364-
required this.name,
365-
required this.description,
366-
required this.renderedDescription,
367-
required this.dateCreated,
368-
required this.inviteOnly,
331+
required super.streamId,
332+
required super.name,
333+
required super.description,
334+
required super.renderedDescription,
335+
required super.dateCreated,
336+
required super.firstMessageId,
337+
required super.inviteOnly,
338+
required super.isWebPublic,
339+
required super.historyPublicToSubscribers,
340+
required super.messageRetentionDays,
341+
required super.streamPostPolicy,
342+
required super.canRemoveSubscribersGroup,
343+
required super.streamWeeklyTraffic,
369344
required this.desktopNotifications,
370345
required this.emailNotifications,
371346
required this.wildcardMentionsNotify,
372347
required this.pushNotifications,
373348
required this.audibleNotifications,
374349
required this.pinToTop,
375350
required this.isMuted,
376-
required this.isWebPublic,
377351
required this.color,
378-
required this.streamPostPolicy,
379-
required this.messageRetentionDays,
380-
required this.historyPublicToSubscribers,
381-
required this.firstMessageId,
382-
required this.streamWeeklyTraffic,
383-
required this.canRemoveSubscribersGroup,
384352
});
385353

386354
factory Subscription.fromJson(Map<String, dynamic> json) =>
387355
_$SubscriptionFromJson(json);
388356

357+
@override
389358
Map<String, dynamic> toJson() => _$SubscriptionToJson(this);
390359
}
391360

lib/api/model/model.g.dart

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

0 commit comments

Comments
 (0)