Skip to content

Conversation

@WesleyAC
Copy link
Contributor

@WesleyAC WesleyAC commented Jun 16, 2021

Related: #3472

@WesleyAC WesleyAC requested review from chrisbobbe and gnprice June 16, 2021 21:14
@WesleyAC
Copy link
Contributor Author

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.

Copy link
Contributor

@chrisbobbe chrisbobbe left a 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.

});

test('mention narrow messages are never muted', () => {
const message = {
Copy link
Contributor

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)?

Copy link
Contributor Author

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 :)

Copy link
Contributor

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;
}
Copy link
Contributor

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)?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, exactly.

Copy link
Member

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.

@WesleyAC WesleyAC force-pushed the show-muted-messages-in-mentioned-narrow branch from f34173b to b93bfb4 Compare June 22, 2021 21:18
@WesleyAC
Copy link
Contributor Author

Updated :)

Copy link
Contributor

@chrisbobbe chrisbobbe left a 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');
Copy link
Contributor

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!

...streamInner,
color: '#123456',
in_home_view: true,
in_home_view: in_home_view === undefined ? true : in_home_view,
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks :)

@WesleyAC WesleyAC force-pushed the show-muted-messages-in-mentioned-narrow branch from b93bfb4 to 035a11d Compare June 22, 2021 21:50
Copy link
Member

@gnprice gnprice left a 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.

Comment on lines 26 to 27
// 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.
Copy link
Member

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.

WesleyAC and others added 5 commits July 19, 2021 15:30
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.
@gnprice gnprice force-pushed the show-muted-messages-in-mentioned-narrow branch from 035a11d to 734c2ef Compare July 19, 2021 22:47
@gnprice gnprice merged commit 734c2ef into zulip:master Jul 19, 2021
@gnprice
Copy link
Member

gnprice commented Jul 19, 2021

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.

gnprice added a commit to gnprice/zulip-mobile that referenced this pull request Jul 20, 2021
This comment had been really just reciting *what* this bit of code
does, not explaining why, as Wesley pointed out:
  zulip#4807 (comment)
@gnprice
Copy link
Member

gnprice commented Jul 20, 2021

(I also just added a mention of #3472 in the description, so that it's possible to navigate to this PR from that issue.)

gnprice added a commit to gnprice/zulip-mobile that referenced this pull request Jul 20, 2021
This comment had been really just reciting *what* this bit of code
does, not explaining why, as Wesley pointed out:
  zulip#4807 (comment)
gnprice added a commit to gnprice/zulip-mobile that referenced this pull request Aug 26, 2021
This comment had been really just reciting *what* this bit of code
does, not explaining why, as Wesley pointed out:
  zulip#4807 (comment)
chrisbobbe pushed a commit to gnprice/zulip-mobile that referenced this pull request Sep 8, 2021
This comment had been really just reciting *what* this bit of code
does, not explaining why, as Wesley pointed out:
  zulip#4807 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants