-
Notifications
You must be signed in to change notification settings - Fork 399
Description
This was brought up here: #1041 (comment).
UserTopicVisibilityPolicy.unknown allows us to deserialize unknown enum values gracefully at the edge.
zulip-flutter/lib/model/channel.dart
Lines 216 to 222 in 9e42f26
| static bool _warnInvalidVisibilityPolicy(UserTopicVisibilityPolicy visibilityPolicy) { | |
| if (visibilityPolicy == UserTopicVisibilityPolicy.unknown) { | |
| // Not a value we expect. Keep it out of our data structures. // TODO(log) | |
| return true; | |
| } | |
| return false; | |
| } |
zulip-flutter/lib/model/channel.dart
Lines 348 to 350 in 9e42f26
| if (_warnInvalidVisibilityPolicy(visibilityPolicy)) { | |
| visibilityPolicy = UserTopicVisibilityPolicy.none; | |
| } |
However, while we manually declare that it wouldn't be possible that we encounter UserTopicVisibilityPolicy.unknown when accessing our internal data store (i.e.: ChannelStore), our type doesn't agree with that, and require the UserTopicVisibilityPolicy.unknown case to be handled for an exhaustive switch. We use assert in such cases, but it is not supposed to be reachable (unless we have a bug).
We should make sure that such an assertion is not needed. To do this, we'll:
- Remove
unknownfromUserTopicVisibilityPolicy. - In the places where it was needed, use a nullable type
UserTopicVisibilityPolicy?instead.
Out of scope
This may or may not apply to other unknown enum values. It would be good to do a sweep of those and decide if we need to follow-up on them as well.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status