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

Rich text editor: improve performance when changing composer mode #7691

Merged

Conversation

jmartinesp
Copy link
Member

@jmartinesp jmartinesp commented Dec 2, 2022

Type of change

  • Feature
  • Bugfix
  • Technical
  • Other :

Content

Store the current MessageComposerMode so we can diff and avoid unnecessary updates.

Also, only change some layout params for the editor if we don't want to animate the full screen change (keeps compatibility with both Element Android and Element X).

Motivation and context

Element X stopped properly responding to input as the renderComposerMode method was being triggered for each change (on Element Android this is not so noticeable). It also had some issues with resizing the editor properly.

As both apps share most of this code, it's better to also handle it properly here.

Screenshots / GIFs

Tests

It's quite difficult to test, as it wasn't a noticeable issue in Element Android.

  • Enable the Rich Text Editor in Labs.
  • Open a room.
  • Select a message and edit or quote it, or reply to it.
  • Exit the editing/replying/quoting mode.

There should be no issues when writing or 'flashes'.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 13

Checklist

@jmartinesp jmartinesp requested a review from bmarty December 2, 2022 14:36
@ElementBot
Copy link

Fails
🚫

node failed.

Log

Error:  Error: Could not find the Dangerfile at tools/danger/dangerfile-lint.js - does a file exist at dangerfile-lint.js in tools/danger?.
    at /usr/src/danger/distribution/platforms/GitHub.js:166:27
    at step (/usr/src/danger/distribution/platforms/GitHub.js:44:23)
    at Object.next (/usr/src/danger/distribution/platforms/GitHub.js:25:53)
    at fulfilled (/usr/src/danger/distribution/platforms/GitHub.js:16:58)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
danger-results://tmp/danger-results-5ac9f88b.json

Generated by 🚫 dangerJS against 09f71af

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

LGTM!

@@ -363,6 +370,9 @@ class RichTextComposerLayout @JvmOverloads constructor(
}

override fun renderComposerMode(mode: MessageComposerMode) {
if (this.composerMode == mode) return
Copy link
Member

Choose a reason for hiding this comment

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

It's worth noting that MessageComposerMode.Quote and MessageComposerMode.Reply are not data class, so maybe == will not work as expected here.

When replying to someone, then (without sending the message), reply to someone else, does the original sender name updates properly?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's worth noting that MessageComposerMode.Quote and MessageComposerMode.Reply are not data class, so maybe == will not work as expected here.

I just changed it so they're data classes too (I don't really remember why they weren't in the first place).

When replying to someone, then (without sending the message), reply to someone else, does the original sender name updates properly?

Yes, both before and after making Reply a data class.

@jmartinesp jmartinesp force-pushed the fix/improve-performance-when-changing-composer-mode branch from 09f71af to f4c071b Compare December 12, 2022 08:32
@ElementBot
Copy link

Warnings
⚠️ Please add a reviewer to your PR.

Generated by 🚫 dangerJS against f4c071b

@ElementBot
Copy link

Warnings
⚠️ Please add a reviewer to your PR.

Generated by 🚫 dangerJS against d8bcaf4

@sonarqubecloud
Copy link

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@jmartinesp jmartinesp requested a review from bmarty December 12, 2022 10:58
Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

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

LGTM!

@jmartinesp jmartinesp merged commit c523e14 into develop Dec 12, 2022
@jmartinesp jmartinesp deleted the fix/improve-performance-when-changing-composer-mode branch December 12, 2022 12:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants