Skip to content

Commit

Permalink
messageActionSheet: Remove "edit","delete" option if time limit exceeds.
Browse files Browse the repository at this point in the history
Currently in zulip web app when edit/delete time limit
exceeds, edit/delete option button is removed.

Handle this feature in mobile version too, like this:

1.If it is "Private messages" narrow remove the buttons.
2.If it is "Topic or Stream messages" narrow keep edit
  button for editing of topic names, remove delete button.

Fixes: zulip#2792,zulip#2793
Signed-off-by: rajprakash00 <rajprakash1999@gmail.com>
  • Loading branch information
rajprakash00 committed Apr 5, 2021
1 parent 5d4603e commit 47acc4e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/message/messageActionSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ export const constructMessageActionButtons = ({
narrow: Narrow,
}): Button<MessageArgs>[] => {
const buttons = [];
const updateMessageTimeLimit = Math.floor((Date.now() / 1000 - message.timestamp) / 60);

if (messageNotDeleted(message)) {
buttons.push(addReaction);
}
Expand All @@ -285,11 +287,19 @@ export const constructMessageActionButtons = ({
if (
message.sender_id === ownUser.user_id
// Our "edit message" UI only works in certain kinds of narrows.
&& (isStreamOrTopicNarrow(narrow) || isPmNarrow(narrow))
&& (isStreamOrTopicNarrow(narrow)
|| (isPmNarrow(narrow)
// if "edit message" time limit exceeds , don't show the edit option button
&& updateMessageTimeLimit < 60))
) {
buttons.push(editMessage);
}
if (message.sender_id === ownUser.user_id && messageNotDeleted(message)) {
if (
message.sender_id === ownUser.user_id
&& messageNotDeleted(message)
// if "delete message" time limit exceeds , don't show the delete option button
&& updateMessageTimeLimit < 60
) {
buttons.push(deleteMessage);
}
if (message.id in flags.starred) {
Expand Down

0 comments on commit 47acc4e

Please sign in to comment.