Skip to content

Commit 03f385a

Browse files
committed
api [nfc]: Explain each missing ChannelPropertyName inline
1 parent 1ee4bb6 commit 03f385a

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

lib/api/model/model.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,14 @@ enum UserRole{
312312
/// in <https://zulip.com/api/register-queue>.
313313
@JsonSerializable(fieldRename: FieldRename.snake)
314314
class ZulipStream {
315+
// When adding a field to this class:
316+
// * Add it to [ChannelPropertyName] too, or add a comment there explaining
317+
// why there isn't a corresponding value in that enum.
318+
// * If the field can never change for a given Zulip stream, mark it final.
319+
// Otherwise, make sure it gets updated on [ChannelUpdateEvent].
320+
// * (If it can change but [ChannelUpdateEvent] doesn't cover that,
321+
// then that's a bug in the API; raise it in `#api design`.)
322+
315323
final int streamId;
316324
String name;
317325
String description;
@@ -369,22 +377,17 @@ class ZulipStream {
369377
/// In Zulip event-handling code (for [ChannelUpdateEvent]),
370378
/// we switch exhaustively on a value of this type
371379
/// to ensure that every property in [ZulipStream] responds to the event.
372-
///
373-
/// Fields on [ZulipStream] not present here:
374-
/// streamId, dateCreated
375-
/// Each of those is immutable on any given channel, and there is no
376-
/// [ChannelUpdateEvent] that updates them.
377-
///
378-
/// Other fields on [ZulipStream] not present here:
379-
/// renderedDescription, historyPublicToSubscribers, isWebPublic
380-
/// Each of those are updated through separate fields of [ChannelUpdateEvent]
381-
/// with the same names.
382380
@JsonEnum(fieldRename: FieldRename.snake, alwaysCreate: true)
383381
enum ChannelPropertyName {
382+
// streamId is immutable
384383
name,
385384
description,
385+
// renderedDescription is updated via its own [ChannelUpdateEvent] field
386+
// dateCreated is immutable
386387
firstMessageId,
387388
inviteOnly,
389+
// isWebPublic is updated via its own [ChannelUpdateEvent] field
390+
// historyPublicToSubscribers is updated via its own [ChannelUpdateEvent] field
388391
messageRetentionDays,
389392
@JsonValue('stream_post_policy')
390393
channelPostPolicy,

0 commit comments

Comments
 (0)