-
-
Notifications
You must be signed in to change notification settings - Fork 651
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
Modify/don't provide 'Reply' option for messages that can't be replied to #3811
Conversation
11105a8
to
3677f1b
Compare
@ray-kraesig please review. |
src/message/messageActionSheet.js
Outdated
if (isAnnouncementOnly) { | ||
reply.title = 'Navigate to 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.
This will permanently modify reply.title
– it'll never be "Reply" again, or at least, not until the application is shut down and restarted.
(The fact that all these action-description-objects are mutable is a bug, not a feature. Please don't exploit it.)
static/translations/messages_en.json
Outdated
@@ -47,6 +47,7 @@ | |||
"Narrow to conversation": "Narrow to conversation", | |||
"Reply": "Reply", | |||
"Add a reaction": "Add a reaction", | |||
"Navigate to topic":"Navigate to 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.
Space after the colon, for consistency. (Ditto for en_GB
.)
src/message/messageActionSheet.js
Outdated
if (!isAnOutboxMessage(message) && !isTopicNarrow(narrow) && !isPrivateNarrow(narrow)) { | ||
if (isAnnouncementOnly) { | ||
if (!isAnOutboxMessage(message) && !isTopicNarrow(narrow) && !isPrivateOrGroupNarrow(narrow)) { | ||
if (isAnnouncementOnly && !ownIsAdmin) { |
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.
These two changes need to be in separate commits.
src/webview/MessageList.js
Outdated
@@ -75,6 +75,7 @@ export type BackgroundData = $ReadOnly<{ | |||
mute: MuteState, | |||
ownEmail: string, | |||
ownUserId: number, | |||
ownIsAdmin: boolean, |
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.
isAdmin
will do. (The own
affix here is of questionable utility anyway, IMO, even where it's grammatical.)
Also, please make sure the ordering of properties is consistent here and below.
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
own
affix here is of questionable utility anyway, IMO, even where it's grammatical.)
I think it's important for "email" and "user id" and "user". There are lots and lots of places we have a variable (or parameter or property) named email
or userId
or user
, and they normally mean "(the email or ID of) the user this widget, or this scrap of data, is about". When it's instead "the user that is looking at the app", that has a very different feel and it's good to make the contrast explicit.
I agree it's not helpful for "is admin", and probably most other possible names.
3677f1b
to
034bf20
Compare
@ray-kraesig have pushed some changes. |
034bf20
to
9c2b533
Compare
Blocked until #3795 is merged. |
9c2b533
to
6fe67ca
Compare
#3795 has been merged :-) |
6fe67ca
to
a4df35a
Compare
Code is good. Some commit-message issues:
The first and second are uninteresting (if it were just those two I would do the copyediting myself before merging), but the third is odd enough that I have to ask what the intent was there. |
Currently, it is possible to select the 'Reply' option from action sheet when in an announcement-only narrow, even if the user is not an admin. Modify 'Reply' option based on whether the user is an administrator. Fixes zulip#3810.
a4df35a
to
20ab23d
Compare
Thanks for reviewing. For your third point - I made a mistake 😓 - Instead of documenting the change I made, I documented the entire feature. I have reworded both the commit messages. |
Remove the 'Reply' option from messageActionSheet when the user is in a group private message narrow.
It's entirely possible to reply to a group PM, though – you can still type into the compose box and send a message and have it be seen; it's just that the current "Reply" option doesn't have an effect there. (This contrasts with announcement-only streams, where even if you send a message to the server it won't be accepted.)
I figured that was all it was, but I had to ask.
Missed the commit summary on the second one, though. 🙂 Amended, and merging. Thanks! |
20ab23d
to
b902d55
Compare
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 @agrawal-d , and thanks @ray-kraesig for the review!
This doesn't actually quite work, because of a subtle issue: the logic is in terms of the current narrow, but the question of whether the user can reply is about the specific message. And we have a lot of possible types of narrows, several of which cut across streams (and across PM conversations): starred messages, @-mentions, searches, and the "All messages" view. (There's also the all-PMs narrow.)
The result is that after this change, we still offer "Reply" even for messages in announcement-only streams, if you're looking at them through one of those narrows.
The right fix for this will involve some different plumbing for the data, which means a good bit of the code involved will be different from this. So I'm going to revert the main commit from this PR and reopen the issue; then we can make another go at it.
The key thing we'll want in the plumbing to make v2 of this is: instead of a prop like isAnnouncementOnly
, let's add streams
to the BackgroundData
type. Then in constructMessageActionButtons
, we can use the message (not the narrow) to look up the Stream
object there, and read off is_announcement_only
.
if (!isAnOutboxMessage(message) && !isTopicNarrow(narrow) && !isPrivateOrGroupNarrow(narrow)) { | ||
if (isAnnouncementOnly && !isAdmin) { | ||
buttons.push('narrowToTopic'); | ||
} else { | ||
buttons.push('reply'); | ||
} | ||
} |
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.
This is too many conditionals in one place 🙂 -- it's more than the reader, in particular the author, can reasonably keep track of in their head.
One symptom of that is that this causes "Narrow to topic" to appear only for non-outbox messages. That doesn't make sense.
This also leaves "Reply" in place when the message is in an announcement-only stream, any time you're in a narrow that isn't specific to the stream. You could be in the all-messages narrow; or starred messages, @-mentions, or a search.
showActionSheet(target === 'header', dispatch, showActionSheetWithOptions, _, { | ||
backgroundData, | ||
message, | ||
narrow, | ||
isAnnouncementOnly, | ||
}); |
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 bonus of using backgroundData
for the plumbing: it saves us from making a longer and longer list here of things we just pass through without change. (That was part of the origin of the backgroundData
object in this message-list code.)
… narrow." This reverts commit 674f9a2 (#3811). That commit fixed only some cases of #3810: it relies on the current narrow rather than the specific message, and so it misses relevant messages when we're in a starred narrow, a search, etc. The right fix will involve plumbing a different set of data down through these layers, rather than `isAnnouncementOnly`, so it'll be simpler to do that fresh than starting from here.
Reverted that commit, as 8f58f46. |
… narrow." This reverts commit 674f9a2 (zulip#3811). That commit fixed only some cases of zulip#3810: it relies on the current narrow rather than the specific message, and so it misses relevant messages when we're in a starred narrow, a search, etc. The right fix will involve plumbing a different set of data down through these layers, rather than `isAnnouncementOnly`, so it'll be simpler to do that fresh than starting from here.
Fixes #3810
Screenshots