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

feature: Add Reactions to messages. #913

Merged
merged 6 commits into from
Aug 17, 2021
Merged

Conversation

zee-bit
Copy link
Member

@zee-bit zee-bit commented Feb 7, 2021

This PR packs a critical feature, that supports adding general reactions to messages. Few highlights of this feature:

  • A new EmojiPicker popup that activates from : hotkey.
  • Search for any emoji in the list through p hotkey.
  • A reaction count beside emoji's that users have reacted with.
  • Emoji list sorted in decreasing order of reaction count, and ascending order of emoji names(if reaction count is same).
  • A CHECK_MARK that indicates emoji's that the current user has reacted with.
  • Mouse support allows toggling reactions and scrolling through mouse events.

Working:

Thanks to @kaustubh-nair for his initial work in #707. I was able to pull some of his changes here, which simplified my work.

@zulipbot zulipbot added the size: XL [Automatic label added by zulipbot] label Feb 7, 2021
@zee-bit
Copy link
Member Author

zee-bit commented Feb 10, 2021

@Ezio-Sarthak Thanks for your review. I'll update this PR after making the desired changes. 👍

Apart, from the code, I also request you to please check out the functionality, if you haven't already and report any bugs/anomalies you find, here or in CZO. This would be really helpful. 😅

@zee-bit zee-bit force-pushed the MessageReaction-#T559 branch 3 times, most recently from 179d6c3 to 4ad9330 Compare February 23, 2021 18:50
@zee-bit zee-bit changed the title [WIP] feature: Add Reactions to messages. feature: Add Reactions to messages. Feb 28, 2021
@zee-bit
Copy link
Member Author

zee-bit commented Feb 28, 2021

@zulipbot add "PR needs review"

@zulipbot zulipbot added the PR needs review PR requires feedback to proceed label Feb 28, 2021
zulipterminal/model.py Outdated Show resolved Hide resolved
@mkp6781
Copy link
Contributor

mkp6781 commented Mar 24, 2021

@zee-bit I'm leaving a few thoughts that came to my mind regarding the commit messages and commit structure.

1st commit: The commit title might need to be rephrased because we intend to "use" the emoji data in self.active_emoji_data. If I am not wrong, I think we use the term "fetch" in connection with obtaining data from the server, which is not the case here.

2nd commit[minor]: First letter of the commit message can be capitalized. :)

3rd commit: This commit has too many changes which makes it tough to be reviewed. So, I think it would be better if we can split it into 2 or 3 commits. Maybe the first one can define EmojiButton, the second one could define EmojiPickerView, and a 3rd one could add support for keys to display the pop up view.

Hope this helps. I am yet to go through the remaining 4 commits.

Copy link
Member

@Ezio-Sarthak Ezio-Sarthak left a comment

Choose a reason for hiding this comment

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

@zee-bit I continue to love this feature, hence decided to give more focussed feedback 👍.

Thanks for splitting the commits, it helped me a lot in understanding the whole story in the PR :)

I see that we'd prefer to include the refactors in the initial commits, though we'd also try keeping it close to the one for which we made this refactor. The refactor commit for PopUpView (2nd commit) and the introduction of EmojiPickerView (7th commit) seems to be quite a gap. (I'm not sure if there were changes based on this refactor between the commits)

I like the intent of using CHECK_MARK for checking if a user has reacted with an emoji or not. This should be a good v0. We might also explore changing the background of emoji count for the same if that makes sense.

tests/model/test_model.py Outdated Show resolved Hide resolved
zulipterminal/model.py Outdated Show resolved Hide resolved
tests/ui_tools/test_buttons.py Outdated Show resolved Hide resolved
tests/ui_tools/test_buttons.py Show resolved Hide resolved
zulipterminal/ui_tools/buttons.py Outdated Show resolved Hide resolved
zulipterminal/ui_tools/boxes.py Outdated Show resolved Hide resolved
zulipterminal/ui_tools/views.py Show resolved Hide resolved
zulipterminal/model.py Outdated Show resolved Hide resolved
@Ezio-Sarthak
Copy link
Member

@zulipbot remove "PR needs review"
@zulipbot add "PR awaiting update"

@zulipbot zulipbot added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs review PR requires feedback to proceed labels Apr 30, 2021
@zee-bit zee-bit force-pushed the MessageReaction-#T559 branch 3 times, most recently from 5b51253 to fa5df75 Compare June 12, 2021 15:18
@zee-bit zee-bit removed the PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback label Jun 12, 2021
Copy link
Collaborator

@neiljp neiljp left a comment

Choose a reason for hiding this comment

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

@zee-bit After merging those model commits I rebased and pushed back the others for convenience. We discussed some points in the stream, and I've left some more inline.

The bugfix seems like a good early commit on the basis that the header/footer shouldn't scroll, so isn't related to fixing the behavior here but can be done first instead. With that and a few other changes as discussed I'm less concerned about the structure/flow at this point and looking forward to this 👍

zulipterminal/core.py Outdated Show resolved Hide resolved
Comment on lines 1933 to 1934
if not fixed_search_caption:
super().__init__(caption="", edit_text=self.search_text)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not being used anywhere? Everything defaults to True?

Copy link
Member Author

@zee-bit zee-bit Aug 12, 2021

Choose a reason for hiding this comment

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

Ahh... This was changed recently when we decided to remove the search hint when the user presses p again. If we go by the current approach i.e. disappearing search hint, then I don't think we need this commit(?), but if we want to show the search caption when the user presses p, then this will be useful.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am still convinced that we dont need to show the search hint when the user presses p, so I've dropped this commit and moved the "initial focus in the search-box" part to the emoji picker commit earlier.

tests/ui_tools/test_buttons.py Show resolved Hide resolved
@@ -297,6 +303,7 @@ def test_keypress_emoji_button(
controller=controller,
emoji_unit=("+1", "1f44d", ["thumbs_up", "like"]),
message=message_fixture,
reaction_count=1,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we know enough here to assert on the reaction count after?

Copy link
Member Author

@zee-bit zee-bit Aug 12, 2021

Choose a reason for hiding this comment

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

We can't assert on the reaction_count currently, because of the below lambda functions. I can instead add case'es to the test in the initial EmojiButton commit and then assert on the reaction_count in this one, but that won't be "just a" keypress check anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added tests for checking reaction_count as well. Let me know if that looks complex. :)

zulipterminal/ui_tools/buttons.py Outdated Show resolved Hide resolved
zulipterminal/ui_tools/views.py Outdated Show resolved Hide resolved
@neiljp neiljp added PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback and removed PR needs review PR requires feedback to proceed labels Aug 11, 2021
@zee-bit zee-bit force-pushed the MessageReaction-#T559 branch 2 times, most recently from e3c70db to 0b2d253 Compare August 12, 2021 22:25
@zee-bit zee-bit added PR needs review PR requires feedback to proceed and removed PR awaiting update PR has been reviewed & is awaiting update or response to reviewer feedback labels Aug 12, 2021
@zee-bit zee-bit force-pushed the MessageReaction-#T559 branch 2 times, most recently from 881562d to 0654ff9 Compare August 14, 2021 20:16
zulipterminal/ui_tools/buttons.py Outdated Show resolved Hide resolved
zulipterminal/ui_tools/buttons.py Outdated Show resolved Hide resolved
zee-bit and others added 6 commits August 16, 2021 22:16
This commit creates an EmojiButton class in buttons.py that will
be used to define button objects for each emoji to contain their
properties and can be passed to emoji picker view to render them.

Tests added.
This commit adds hotkeys for opening/closing of emoji picker
popup, and searching for emojis from the popup.
The current proposed key for opening/closing emoji popup is
':'(colon), and for searching a particular emoji from the popup
is 'p'.

docs/hotkeys.md regenerated.
A new pop-up EmojiPickerView will be triggered on pressing ':' key on a
message. This view will be used to search and select the emoji that a
user wants to toggle (react/unreact with). The selection will be applied
only after exiting the popup.

This currently only provides a UI for adjusting the thumbs-up/+1 emoji,
as currently achievable via `+`, but will be extended in future.

A minimal search-box implemented on top of PanelSearchBox is added,
which can be triggered on pressing 'p' key from Emoji picker view. The
search logic will be added in subsequent commits, however currently only
one emoji is in the list.

Tests added.

Co-authored-by: Zeeshan <equbalzeeshan@gmail.com>
This commit completes the logic of searching for emojis from the
EmojiPickerView on pressing 'p' key. The search is kept dynamic
for faster reacting to messages.

The emoji list now also displays the full list of emoji's present
in model.active_emoji_data. A few bugs related to displaying empty
emoji list and searching in general have also been fixed.

Tests added and amended.
A new reaction_count field is added to the EmojiButton class to keep
in check the number of reactions with a particular emoji on a message.

The EmojiPicker view also shows the count of reactions of a particular
emoji beside emoji_name, and the list is sorted in descending order of
emoji_count, then in ascending order of emoji_names if the count is equal.

Tests amended.
This commit adds support for handling mouse_events from the emoji
picker view, so that users can toggle reactions and scroll the view
using their mouse.

The mouse_event looks for left-click for toggling message reactions
and up/down scroll to scroll through the list of emoji's from the
picker. The commit is kept at the last since having mouse support is
one of our least priorities for now, and providing basic functions
bug-free should always come first.

Tests added.
@neiljp neiljp added this to the Next Release milestone Aug 17, 2021
@neiljp neiljp added area: UI General user interface update missing feature: user A missing feature for all users, present in another Zulip client and removed further discussion required Discuss this on #zulip-terminal on chat.zulip.org PR needs review PR requires feedback to proceed labels Aug 17, 2021
@neiljp
Copy link
Collaborator

neiljp commented Aug 17, 2021

@zee-bit Thanks for your work taking this to the finishing line, including the already-merged commits 👍
I'm merging now that the CI has passed 🎉

This took a little longer to review than I'd hoped, and things may be simpler to read if we make a few changes later, but this is a great feature and one that we've been looking forward to for some time :) The simpler logic we achieved at the end has definitely helped with readability 👍

I know there is plenty else to be getting on with, but it'd be great to discuss follow-up ideas in the stream - I know we discussed a few already, and we can perhaps write up a tracking issue to summarize afterwards. Another that came to mind is if one applies multiple reactions, then the changes already made aren't shown during subsequent searches, so 'saving' the reactions (esc/:) can cause unexpected results - maybe we could keep showing the to-be-changed reactions during a search?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: UI General user interface update missing feature: user A missing feature for all users, present in another Zulip client size: XL [Automatic label added by zulipbot]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants