Remove unknown from UserTopicVisibilityPolicy #2095
+217
−80
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes: #1074
Changes made with reasoning:
2.example_data.dart- made UserTopicVisibility needed to be made nullable so tests can construct null edge cases and normal cases. Same for store.dart
3 .channel.dart- changed position of _warnInvalidVisibilityPolicy up to ChannelStore mixin so it can be accessed by all methods.
handleUserTopicEvent- Separated null and .none handling here so that later if logging required can be done easier
skips adding any null entry to the map
If event.visibilityPolicy is null and if there was no previous entry, it just returns (skips it)
If there was a previous entry, it removes that entry. Drop the stream map if it becomes empty
willChangeIfTopicVisibleInStream and willChangeIfTopicVisible - Added null checks that return UserTopicVisibilityEffect.none when visibilityPolicy is null since its case for .none is just return (do nothing)
Tests added:
does not add a new entry with null for that topic
if there was an old entry, it removes it from topicVisibility
Checks to check that invalid visibility_policy (null) does not cause any visibility change
Passed all tests