Skip to content
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

BUG: Editing of Audio, Video and File Message #697

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

dhairyashiil
Copy link

@dhairyashiil dhairyashiil commented Dec 19, 2024

Brief Title

Updated handleEditMessage functionality, and added validation for audio, video, and file message

When a user sends an audio/video/file message in the chat and clicks on the "Edit" option, they can record another audio or video/upload new file. However, the User should not be able to edit audio or video, or file messages. Instead, they can delete the message and send a new one

Acceptance Criteria fulfillment

  • When the user attempts to edit an audio/video/file message, a popup will appear stating 'Editing Audio/Video/File messages is not supported at the moment.''

Fixes #696
Fixes #698

Screenshots

Screenshot (1448)
and
Screenshot (1450)

PR Test Details

Note: The PR will be ready for live testing at https://rocketchat.github.io/EmbeddedChat/pulls/pr-697 after approval.

@smritidoneria
Copy link
Contributor

Instead of showing the error, it's better to hide the option of edit for the audio/ video message.
What do you think @Spiral-Memory

@Spiral-Memory
Copy link
Collaborator

Yes better

@devanshkansagra
Copy link
Contributor

devanshkansagra commented Dec 19, 2024

But I think it will be difficult

Instead of showing the error, it's better to hide the option of edit for the audio/ video message. What do you think @Spiral-Memory

Not only for audio / video but all types of attachments -> audio, video, file and image

@abirc8010
Copy link
Contributor

Not only for audio / video but all types of attachments -> audio, video, file and image

I think for files , images we can keep the edit option to edit the file description as in RC

@smritidoneria
Copy link
Contributor

Not only for audio / video but all types of attachments -> audio, video, file and image

I think for files , images we can keep the edit option to edit the file description as in RC

I think this is better

…ed previous approach of showing popup message
@dhairyashiil
Copy link
Author

Hello Zishan (@Spiral-Memory), I have changed my approach from showing a popup to hiding the 'edit' option for audio/video messages.

Thank you, Abir (@abirc8010) and Smriti (@smritidoneria) for your comments. At first, I thought of hiding the 'edit' option for all messages except text, but because of your comments, I understood that this is the better approach.

Video:
We cannot edit audio and video messages, but we can update the descriptions of both file and image messages.

hide.edit.option.for.audio.and.video.messages.mp4

@@ -120,7 +120,7 @@ export const MessageToolbox = ({
id: 'edit',
onClick: () => handleEditMessage(message),
iconName: 'edit',
visible: message.u._id === authenticatedUserId,
visible: (message.u._id === authenticatedUserId) && (message.files?.[0].type !== 'audio/mpeg') && (message.files?.[0].type !== 'video/mp4'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

But not all audio and video are in MPEG/MP4 format, right?

We might need to create a mapping for suitable formats and then try

Copy link
Author

Choose a reason for hiding this comment

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

Hello Zishan, Currently all our audios are of type: 'audio/mpeg' & videos are of type: 'video/mp4'

These values are hardcoded in the 'AudioMessageRecorder.js' and 'VideoMessageRecoder.js' files.

image

image

So, I think the above condition will work for all audio and video files since we currently have only one format.

If we later introduce new formats for audio and video, we will update this logic accordingly.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay, this is only for the audio and video message recorded directly ?

And not for the file sent ?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, Correct.

@abirc8010
Copy link
Contributor

I think instead of completely removing the edit option , we can disable the audio, video and file option in editing mode like in RC.
So that user can edit description.

@Spiral-Memory
Copy link
Collaborator

I think instead of completely removing the edit option , we can disable the audio, video and file option in editing mode like in RC. So that user can edit description.

Yes better!

@Spiral-Memory
Copy link
Collaborator

Please resolve the conflict

@dhairyashiil
Copy link
Author

I think instead of completely removing the edit option , we can disable the audio, video and file option in editing mode like in RC. So that user can edit description.

Hello Abir, right now I have not disabled edit option for files, user can still edit description for file messages.

Currently, our Embedded Chat approach is slightly different for audio and video scenarios than RC.
In RC while recording and sending audio and video messages, we give description as well But it is not the same for Embedded.

Screenshots from RC-
For Audio:
image

For Video:
image

On Embedded we directly send the audio and video messages, without asking for a description.

@dhairyashiil
Copy link
Author

Please resolve the conflict

Yes, Zishan. resolving now

@dhairyashiil
Copy link
Author

Hello Zishan (@Spiral-Memory), resolved the conflict and format check issue.

since it's my first PR I apologize for any inconvenience caused by my lack of experience, do give me a review so that I can make better PRs

@Spiral-Memory
Copy link
Collaborator

No worries @dhairyashiil

visible: isAllowedToEditMessage,
visible:
isAllowedToEditMessage &&
message.files?.[0].type !== 'audio/mpeg' &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of checking here directly, make a variable for this check and use it here.

Copy link
Author

Choose a reason for hiding this comment

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

Done. Thank you, Zishan.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants