-
-
Notifications
You must be signed in to change notification settings - Fork 675
Show muted messages in mentioned narrow #4807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show muted messages in mentioned narrow #4807
Conversation
|
This isn't exactly the right approach in the long term, I think (#3542 has the start of a better solution), but I think that this is a useful tactical fix anyways. |
chrisbobbe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @WesleyAC! See a few small comments below.
src/utils/__tests__/message-test.js
Outdated
| }); | ||
|
|
||
| test('mention narrow messages are never muted', () => { | ||
| const message = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, these new objects aren't well-typed. Want to get the file type-checked and start using exampleData (e.g., eg.streamMessage)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really want to, but I've gone ahead and done it. It is nice to have this typed :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can relate! 😅 Thanks for doing this. 🙂
|
|
||
| if (isMentionedNarrow(narrow)) { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the other early returns each have a comment explaining the reasoning. Could we add one that makes this one clearer (in particular, that this is just a tactical fix for now)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah. I don't really like the other comments (they're explaining what the code's doing, not why), but this is a case where explaining why would be useful. I'll add that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, exactly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new comment is good!
I agree about the existing comments. The one on "when narrowed to topic" is especially unhelpful. I think a proper fix for that comment (and that conditional certainly does need some kind of comment) would involve writing some jsdoc to articulate what this function's semantics is supposed to be in the first place.
… And then where that leads, I think, is that this is really a helper function specialized for its one caller, getShownMessagesForNarrow, and should appear next to that function. (That is: it's hard to coherently write down what its meaning is supposed to be without effectively saying "this says whether getShownMessagesForNarrow should filter this message out".) And in turn looking at that call site… it should really get inlined there, because the top level of its control flow is mostly about switching on the type of narrow, and in many cases we can skip the filter entirely.
Anyway, none of that needs to happen in this PR. Perhaps after this is merged, I'll go and try cleaning that up and writing associated jsdoc.
f34173b to
b93bfb4
Compare
|
Updated :) |
chrisbobbe
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! See one nit below.
Also I wonder if @gnprice wants to check that this is a good tactical fix to make? I think it is, but I might be missing something.
| subject: 'some topic', | ||
| }; | ||
| const narrow = topicNarrow('some topic'); | ||
| const narrow = topicNarrow('stream', 'some topic'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, nice to get this topicNarrow call fixed!
src/__tests__/lib/exampleData.js
Outdated
| ...streamInner, | ||
| color: '#123456', | ||
| in_home_view: true, | ||
| in_home_view: in_home_view === undefined ? true : in_home_view, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could shorten to in_home_view ?? true.
This expression has the one difference that it also gives true when in_home_view is null. But in_home_view won't be null because of its type annotation as an optional boolean property of the args object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Thanks :)
b93bfb4 to
035a11d
Compare
gnprice
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @WesleyAC and @chrisbobbe ! One comment below, which I'll fix and then merge.
src/utils/message.js
Outdated
| // problem we have with muted mentioned messages, which is that they show up | ||
| // in the count for the "Mentions" tab, but not in the actual narrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One confusing thing in this comment: it describes the state before this bit of code was added, but at the time the comment is added, it's no longer accurate. Muted mentioned messages do now show up in the actual narrow under the "Mentions" tab.
I didn't notice that when first reading this comment -- it's subtle when reading now, when we're thinking about this change itself 😉 and so the previous state is salient in our minds. But in a future when someone (us included) is just trying to understand how the code is and doesn't remember this bugfix, it'll be confusing because the comment is saying one thing and then the code is ensuring the opposite.
About to merge, so I'll just fix this.
Currently, we don't show muted messages in the mentioned narrow. This is confusing and inconsistent with the webapp. This commit fixes that. We should do a more thorough audit of this code, and compare it to the webapp version. I haven't attempted to do that right now, since this small tactical fix seems important and high-priority. Related: zulip#3472
This follows up on adding types and using exampleData, to further make it easier to scan through these tests and see what scenarios they cover and don't cover.
The test says the message is muted if the stream is *not* in the "mute list"? Is that backward? … Ah, no, the point is that this covers when the stream isn't in the *subscriptions* list -- i.e., you're not subscribed. Clarify that in the code, with a comment on why this case isn't just an error case that shouldn't happen, and why it gets this behavior; and fix the test description too. Also add a test for the basic happy case, where you *are* subscribed and it isn't muted. That's what the next few cases are implicitly comparing against -- it wouldn't be very interesting that they returned false if this one didn't return true.
035a11d to
734c2ef
Compare
|
And merged! I also added a couple of followup commits -- the nice new well-typed, shorter version of the tests made it easier to see what was going on there, and surfaced some things to fix. I have some more I'll send as a new PR, too. |
This comment had been really just reciting *what* this bit of code does, not explaining why, as Wesley pointed out: zulip#4807 (comment)
|
(I also just added a mention of #3472 in the description, so that it's possible to navigate to this PR from that issue.) |
This comment had been really just reciting *what* this bit of code does, not explaining why, as Wesley pointed out: zulip#4807 (comment)
This comment had been really just reciting *what* this bit of code does, not explaining why, as Wesley pointed out: zulip#4807 (comment)
This comment had been really just reciting *what* this bit of code does, not explaining why, as Wesley pointed out: zulip#4807 (comment)
Related: #3472