Page MenuHomePhabricator

[web] Remove creating a new siedebar/thread with an empty message
ClosedPublic

Authored by inka on Jul 26 2022, 4:28 AM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, May 10, 12:01 PM
Unknown Object (File)
Thu, May 2, 7:06 PM
Unknown Object (File)
Apr 11 2024, 3:31 PM
Unknown Object (File)
Apr 11 2024, 3:31 PM
Unknown Object (File)
Apr 11 2024, 3:31 PM
Unknown Object (File)
Apr 11 2024, 3:31 PM
Unknown Object (File)
Apr 11 2024, 3:31 PM
Unknown Object (File)
Apr 11 2024, 3:29 PM

Details

Summary

It was possible on web to create a new sidebar or thread with an empty (or including only
whitespaces) message. It is no longer so.
Linear issue:
https://linear.app/comm/issue/ENG-1437/sending-empty-message-on-web-is-possible-for-pending-chat-and-creates

Test Plan

Check that it is no longer possible to create a new sidebar/thread with an empty/including only whitespaces message, but is
possible with a non-empty text message or a multimedia message.
Additionally check that sending text and multimedia messages is possible, including those where
the multimedia is chosen from a finder, pasted from a clipboard and drag-and-dropped.

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

inka requested review of this revision.Jul 26 2022, 4:42 AM
inka edited the summary of this revision. (Show Details)
jacek requested changes to this revision.EditedJul 26 2022, 6:22 AM

I think the title of the diff should reference any chat - not only sidebar.

The solution prevents creating a thread when trying to send an empty text message, but introduces another issues. Now it's impossible to send multimedia message without any text (because this.multimediaInput?.value.trim() is always '', even if we have multimedia message - but only if we drag-and-drop or paste message - if we select one using Finder, it works correctly), and pressing enter in empty text input bar creates newline what is probably not desired behavior (as every other pressing "enter" send new message)

What is interesting here, we already trim the message (https://github.com/CommE2E/comm/blob/e2d045ebf313b21a90a0efa4b6948b9b815b3fce/web/chat/chat-input-bar.react.js#L352), and prevent sending it if it contains only whitespaces or is empty.
The source of the problem may be in createMultimediaMessage (https://github.com/CommE2E/comm/blob/e2d045ebf313b21a90a0efa4b6948b9b815b3fce/web/input/input-state-container.react.js#L1016-L1051) which is executed every time, even when the message is empty - probably it may be creating new thread.

Maybe we should just check if multimedia input exists when before executing createMultimediaMessage to prevent thread creation?

It's worth to notice, that all web app input is kept in inputState object, so all actions on input should not be performed directly on input elements (this.textarea?.value), but on InputState (this.props.inputState.draft)

This revision now requires changes to proceed.Jul 26 2022, 6:22 AM

Thank you for such a detailed review, @jacek!

web/chat/chat-input-bar.react.js
347–348 ↗(On Diff #14954)

Agree with everything @jacek mentioned, but a separate note: we should never nest conditionals like this. The same thing can be achieved with a single if statement

inka retitled this revision from [web] Remove creating a new siedebar with an empty message to [web] Remove creating a new siedebar/thread with an empty message.Jul 27 2022, 5:56 AM
inka edited the summary of this revision. (Show Details)
inka edited the test plan for this revision. (Show Details)
tomek added 1 blocking reviewer(s): jacek.

Seems to work correctly now!

This revision is now accepted and ready to land.Jul 28 2022, 4:00 AM