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

[wip] popovers: rendering the emoji picker only once. #4301

Closed
wants to merge 3 commits into from
Closed

[wip] popovers: rendering the emoji picker only once. #4301

wants to merge 3 commits into from

Conversation

tejaskasetty
Copy link
Collaborator

Fix to #4300
The rendering of emoji for the emoji picker is made only once when the emoji Picker UI is first used.
Rest of the requests just toggles the already rendered emoji picker.

Notable changes - Earlier when ever the emoji picker was closed the focus on the compose text box would be removed. In this commit, when the emoji picker is closed the compose text box remains in focus. And this happens also when we open the emoji picker. This change will be reverted back if not needed.

Observations - There are other areas like this if corrected can improve the efficiency of the emoji picker UI on the frontend. I will look for them and work on improving them.

@smarx
Copy link

smarx commented Mar 25, 2017

Automated message from Dropbox CLA bot

@tejaskasetty, it looks like you've already signed the Dropbox CLA. Thanks!

@tejaskasetty
Copy link
Collaborator Author

tejaskasetty commented Mar 25, 2017

This also would be a way for progress on #1956 . Which deals with improvement in performance of emoji picker, which I have been working on parallely.

@showell
Copy link
Contributor

showell commented Mar 25, 2017

Hi @tejaskasetty, can you fix the commit messages to conform to our guidelines here?:

https://zulip.readthedocs.io/en/latest/version-control.html#commit-messages

@tejaskasetty
Copy link
Collaborator Author

yeah sure.

@tejaskasetty
Copy link
Collaborator Author

The thing is, I would like to just submit one proper commit. The multiple commits that i submitted were because it initially didn't pass the Travis CI build. How can i do that? I m really sorry, I should have read the commit discipline. Now i know how to write a proper commit message. And also I m still getting familiarized with git.

@showell
Copy link
Contributor

showell commented Mar 25, 2017

@tejaskasetty, It is very common for contributors to have issues understanding git, so please don't worry, we're here to help. In order to squash your commits into one proper commit, you will want to learn how to do an interactive rebase. If you go on to the "development help" stream on chat, there should be multiple folks that can walk you through this, although expect some delay for help during the weekend.

@adnrs96
Copy link
Member

adnrs96 commented Mar 25, 2017

You can squash all the commit's into one using an interactive rebase in git.
Reading this might be useful.
Also Zulip has a git guide here.

@zulipbot
Copy link
Member

Hello @zulip/server-emoji members, this pull request references an issue with the "area: emoji" label, so you may want to check it out!

@tejaskasetty
Copy link
Collaborator Author

tejaskasetty commented Mar 25, 2017

Thanks a lot. It was very informative. Got to learn more about Git. By the way, how is the updated commit. Is this according to the guidelines?

@@ -519,10 +521,14 @@ exports.register_click_handlers = function () {
if (emoji_map_is_open) {
// If the popover is already shown, clicking again should toggle it.
popovers.hide_emoji_map_popover();
return;
} else { // popovers.hide_all();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you want to remove the above comment.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah. I kept it so that it would remind me to check areas like this, where there has been unwanted calls to hide all popovers. so they I could understand them. so that i could optimize other areas like this as well. I forgot to remove it later.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think that it is an unwanted call. Purpose of this call is to hide other popovers like message actions popover, if they are open before opening the emoji picker popover. I think you should add it back.

@showell
Copy link
Contributor

showell commented Mar 26, 2017

The code here looks pretty straightforward, and I appreciate the detail of the commit message.

I'd like to reword the first line of the commit message a bit. Since we have two different emoji pickers, and I believe this is for the compose box, say this: compose: Render the emoji picker only once.

Copy link
Member

@HarshitOnGitHub HarshitOnGitHub left a comment

Choose a reason for hiding this comment

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

@tejaskasetty It is looking good but I think it is still not complete yet. You need to re-render the emoji pickers in case a realm emoji is added/deleted as pointer out by Tim! :)

@tejaskasetty
Copy link
Collaborator Author

tejaskasetty commented Mar 27, 2017

@HarshitOnGitHub yeah you are right. I will add that case and submit.

@tejaskasetty
Copy link
Collaborator Author

@showell. I ll change commit header. Actually, I m also working on unifying the two different emoji pickers as well. I m going through the code base to get the ideas of all the places where this occurs. Going through the code base is taking a bit of time. Once i cover all the related files, i will start of with that too.

@showell showell changed the title popovers: rendering the emoji picker only once. [wip] popovers: rendering the emoji picker only once. Mar 27, 2017
@showell
Copy link
Contributor

showell commented Mar 27, 2017

I added "wip" to the PR title to indicate this is still a work in progress.

@tejaskasetty
Copy link
Collaborator Author

okay

@timabbott
Copy link
Sponsor Member

@tejaskasetty can you resolve the outstanding feedback and let us know when this is ready for review?

@tejaskasetty
Copy link
Collaborator Author

tejaskasetty commented Apr 7, 2017

I m really sorry, for the delay. I was checking through the server side code for - "How the case of updating a realm_emoji was handled. Took some time jumping between various files trying to understand the server part. Later realized that, whenever a realm_emoji was added, in server_events.js

case 'realm_emoji':
        emoji.update_emojis(event.realm_emoji);
        admin.populate_emoji(event.realm_emoji);
        break;

this case would be triggered. So, i didn't have to change/add anything on the server side.
I just added a function call in the above case to reset the emoji_is_rendered in popovers to false. So, the emojis are rendered again when the emoji set is updated.

@tejaskasetty tejaskasetty reopened this Apr 7, 2017
@tejaskasetty
Copy link
Collaborator Author

Sorry accidently closed it

@tejaskasetty
Copy link
Collaborator Author

tejaskasetty commented Apr 7, 2017

Coming back to the issue, the mistake was i thought it was not handled on the server side. So, simply went through a lot of server side code.
After adding the fix in server_events.js, I tested it by adding custom emoji's using the administrator account and checked the working. Whenever the new emoji is added, the the emoij set will be updated and rendered again.

@showell
Copy link
Contributor

showell commented Apr 7, 2017

It looks like you need to fix the node test for dispatch.js, which should be a one-line fix, but I'm not sure.

You can run ./tools/test-js-with-node to reproduce.

I'm not sure about the other Travis errors--they may have been flakes unrelated to your changes.

@tejaskasetty
Copy link
Collaborator Author

tejaskasetty commented Apr 10, 2017

@showell I have made the correction in emoji.update_emojis to support deletion of emoji and added the popovers.js dependecy in dispatch.js and the tests seems to pass now . Please review.

Copy link
Member

@HarshitOnGitHub HarshitOnGitHub left a comment

Choose a reason for hiding this comment

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

Left a few comments and please have proper capitalization and punctuation in your commit messages, otherwise looking good to me. :)

@@ -380,6 +380,10 @@ function user_sidebar_popped() {
return current_user_sidebar_popover !== undefined;
}

exports.reset_emoji_map_is_rendered = function () {
Copy link
Member

Choose a reason for hiding this comment

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

Minor but I would call it something like reset_emoji_popover().

@@ -29,6 +29,7 @@ exports.emoji_name_to_css_class = function (emoji_name) {

exports.update_emojis = function update_emojis(realm_emojis) {
// Copy the default emoji list and add realm-specific emoji to it
exports.realm_emojis = {};
Copy link
Member

Choose a reason for hiding this comment

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

You can add a comment here explaining why this is needed.

@tejaskasetty
Copy link
Collaborator Author

@HarshitOnGitHub Thanks, for the review. I made the changes. And updated the commit messages. I'll be careful about these aspects in future commits.

* Whenever the emoji picker is opened a call is made to render
  the emoji's. This rendering happend everytime the emoji picker
  was opened. Thus, resulting in duplicates of emoji's getting
  appended in the emoji picker over multiple open and close.

* This commit, is a fix to render the emoji's only once when the
  emoji picker is opened for the first time. Further calls just
  toggles the emoji picker showing the already rendered emoji's.
  This enhances the performance of Emoji picker considerably
  because there is no overhead of making a request to get the emoji's
  from the server, each time the emoji picker is opened.

* Other changes -- on closing the emoji picker, the compose box
  remains in focus.

Fixes: #4300.
See Also: #3952.
@adnrs96
Copy link
Member

adnrs96 commented Apr 15, 2017

@tejaskasetty It seems from the last commit that you used the merge branches workflow whereas Zulip prefers rebase. Would you mind rebasing your branch instead of doing a merge.
You might find this useful.

@tejaskasetty
Copy link
Collaborator Author

yeah I realized that. So, finished rebasing will push it to my remote branch now.

* reset the emoji popover in case of an event
regarding update of realm_emoji.
* test-node-with-js: Add dependency - popovers module;
In dispath.js to support popovers object.
@timabbott
Copy link
Sponsor Member

Nice, this version is really clean. Merged, thanks @tejaskasetty!

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.

None yet

7 participants