-
-
Notifications
You must be signed in to change notification settings - Fork 832
Conversation
Karma tests are failing for reasons unrelated to this PR. Will have a look to fix them in a different PR. |
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.
lgtm - only thing I wondered about was why have a separate class for transferring state between editors rather than just passing the model between them.
Because things like PillCandidatePart have indirect references to the MessageEditor react component to open the auto completion, hence the (de)serialization. Also, we need to pass the caret. And I didn't want to have to pass two props all the way down from TimelinePanel to MessageEditor so I grouped it in a new class. |
fcead46
to
89cc458
Compare
9223e96
to
8b16f91
Compare
With relations to unsent events supported in matrix-org/matrix-js-sdk#947, this allows editing unsent messages in the UX.
First, it considers pendingEvents while arrow-upping/downing between events to edit.
Second, it does some hackery to allow an uninterrupted experience when the remote echo arrives. When editing an unsent event and the remote echo arrives, the editor will get unmounted and mounted again under a new event tile (with a new key=eventId).
The editor state (current editor model and caret position) needs to be transferred from one editor instances to the new to allow uninterrupted editing. As the editor model depends on the messageeditor react component to be able to trigger autocomplete, we're serializing the model and deserializing it again in the new component.
To keep this state around while the editor is torn down, a new class,
EditorStateTransfer
, is created, which is passed down from theTimelinePanel
all the way down to theMessageEditor
, and only replaced when theedit_event
action (which is what triggers an edit) is received.The local echo of editing an unsent event doesn't work yet, as the whole relations infrastructure is implemented in the timelineset, and not present in the pendingEvents... Once the remote echo for the edit arrives, everything falls into place though.
Implements element-hq/element-web#9860
Fixes element-hq/element-web#9864
Needs matrix-org/matrix-js-sdk#947