Commit Graph

26 Commits

Author SHA1 Message Date
Cory Lynch 08f1c86041 Make reaction picker case-insensitive.
The search bar for picking message reactions now is case-insensitive,
since that's a better user experience, and there isn't a clear use
case for capital letters in emoji names.

Fixes #4666.
2017-05-11 19:10:21 -07:00
Tejas Kasetty 9b9c323314 emoji picker: Move cursor to end of filter string when focusing.
This is a much less annoying behavior than the Chrome browser default.

Explanatory comment added by tabbott, thanks to Steve Howell for the
research.

Fixes #4604.
2017-05-11 18:54:44 -07:00
Steve Howell d7813ee6b3 reactions: Remove unneeded message_store.get() calls.
Both callers to get_user_list_for_message_reactions() already
had a message object, so there was no need to pass in an id
just to fetch it from message_store again, so now the first
parameter is message, not message_id.
2017-05-11 09:39:17 -07:00
Steve Howell 87f5c22593 Simplify how we find the current user's emoji reactions.
This adds the current_user_has_reacted_to_emoji() helper.

This new helper is easier to use and slightly more efficient
than calling get_user_list_for_message_reaction() and then
indexOf().

This also replaces one call to get_user_list_for_message_reaction()
with a list of user_ids that we already had locally.

The node tests were improved a bit here, including a minor
whitespace fixup.
2017-05-11 09:39:17 -07:00
Tejas Kasetty 5dd5c84854 Add support for emoji picker hotkeys in compose context.
This is a follow-up to merging the compose and reactions emoji
pickers.  The logic for what happens when the user picks an emoji via
the hotkeys (i.e. hits `enter`) was still attempting to add a reaction
to the currently selected message unconditionally.

This commit adds a check in the two `enter` key code paths, and does
the correct thing in each case.

Fixes #4736.
2017-05-10 16:26:58 -07:00
Tim Abbott cfeff245c1 emoji: Manage Zulip emoji as a custom/extra realm emoji.
This is prerequisite for converting our emoji system to work off of
iamcal sprite sheets.

Also, fixes #4308.
2017-04-30 16:40:31 -07:00
Jack Zhang df817f12f4 emoji: Rename reaction-popover to emoji-popover.
The name emoji-popover should now be more appropiate, as there's no more
need to distinguish between reacting to messages and composing messages.
2017-04-30 15:15:33 -07:00
Jack Zhang a9505654da emoji: Replace the old compose emoji picker with the reactions picker.
This removes the old compose emoji picker in its entirety, changing
the few callbacks needed to launch the reactions-style emoji picker
instead and hook it up properly.

Callbacks for reactions and composing messages are distinguished by
selecting for, respectively, the .reaction and .composition classes.

Fixes #4122.
2017-04-30 15:14:42 -07:00
Jack Zhang f8b3ce7d15 emoji: Move all emoji picker logic/events into emoji_picker module.
Added emoji_picker.js to static asset pipeline.
2017-04-30 14:13:36 -07:00
Joshua Pan a7327422a8 reaction.js: Create reaction_navigate(). 2017-04-19 06:17:15 +00:00
Joshua Pan abda711c66 reaction.js: Extract reaction_show_list functions.
This creates get_emoji_at_index() and
find_index_for_emoji() functions, which search for
emojis and indices in reactions_show_list. Update
maybe_select_emoji with newly created functions.
2017-04-19 06:17:15 +00:00
Joshua Pan e075c84ca5 reaction.js: Maintain reaction_show_list.
This updates reaction_show_list whenever the popover
gets opened and whenever the search filter for reactions
gets used.
2017-04-19 06:17:15 +00:00
Joshua Pan cd28ea6d07 reaction.js: Update toggle_reaction().
Created get_selected_emoji() function.
toggle_reaction() now doesn't require emoji_name
and automatically looks for a selected_emoji
if possible.
2017-04-19 06:16:30 +00:00
Steve Howell cf6545a71f reactions: Only warn for unknown user ids.
If we get reactions for deactivated users, or otherwise missing
users, we only issue a blueslip warning now.  The function
get_message_reactions() was indirectly causing blueslip errors
before this fix, but we can downgrade to warnings now that this
function has better unit tests around it.

We eventually want to track deactivated users on the client.

Fixes #4289
2017-03-26 11:51:36 -07:00
Steve Howell 80addd902c Extract local vars in get_message_reactions(). 2017-03-26 11:39:05 -07:00
Steve Howell b3e4aa4c44 reactions: Downgrade blueslip error to a warning.
When we get a server error for adding/removing a reaction, we
no longer make a blueslip error, since it is somewhat common for
users to retry actions before the server sends an event.  The
code comment that is part of this commit explains this further.

Fixes #4290.
2017-03-24 18:24:15 -07:00
Joshua Pan b600e4d594 Pressing enter in reactions search picks first reaction. 2017-03-19 14:36:34 -07:00
Joshua Pan c8f2da3f3e reactions.js: Refactor reaction_popover_reaction_on_click. 2017-03-19 14:25:10 -07:00
Steve Howell 203ced0ee6 minor: Rename var in filter_emojis(). 2017-03-19 06:25:10 -07:00
Sourav Badami 4616ee7762 Enable display of emoji as their alt codes in reactions.
This currently only supports this in emoji reactions, not in actual
emoji in message bodies, but it's a great start for people who want a
text-only view.

Tweaked to update the text by tabbott.

Fixes #3169.
2017-03-03 15:19:34 -08:00
hackerkid 10324ba592 Change reaction button color when user reacts.
This makes it easy to see whether you were one of the people who
reacted to a give message.
2017-02-21 23:09:46 -08:00
Tim Abbott 7badc39b02 reactions: Fix exceptions reacting to locally echoed messages.
Previously, we were incorrectly not updating the data-message-id used
in the .message_reactions section to use the final ID when
echo.reify_id was called.

This meant in particular that if someone else reacted to a message you
sent, and you clicked it to share the reaction, you'd get an exception.
2017-02-07 14:13:29 -08:00
Tim Abbott 9821b3ebef reactions: Fix JS error for not-yet-fetched messages. 2017-01-17 00:10:41 -08:00
Tim Abbott 998dff9e50 lint: Add dangling commas in JavaScript objects. 2017-01-11 15:23:42 -08:00
Tim Abbott ec3e5e844a reactions: Clean up popovers and hover logic.
Previously, the emoji reactions popovers were keyed off the
edit_content area, which is problematic because that area was
created/deleted on hover, resulting in orphaned popovers (which
wouldn't close properly normally).  That had been hackishly addressed
in the original PR with the overbroad `$('.popover').remove();`.  To
remove that, we fix the actions popover to always be based on an
element that exists in the page.

There probably more to do here, but this is good enough to merge emoji
reactions and iterate from here.
2016-12-30 21:42:54 -08:00
Arpith Siromoney 9c64a08cad Add frontend support for emoji reactions.
This commit replaces the placeholder "clipboard" button with a reaction button.
This is done on any message that can't be edited. Also, on messages sent by
the user the actions popover (toggled by the down chevron icon) contains
an option to add a reaction.

When clicked, a popover with a search bar and a list of emojis is displayed.
If the right sidebar is collapsed (the viewport is small), the popover is placed
to the left of the button.
Focus is set to the search bar. Typing in the search bar filters emojis.

Emojis with which the user has reacted to this message are highlighted.
Clicking them sends an API request to remove that reaction.
Clicking on non-highlighted emojis sends an API request to add a reaction.
When the popover loses focus it is closed.

The frontend listens for reaction events. When an add-reaction event is
received, the emoji is displayed at the bottom of the message with a
count initialized to 1. If there was an existing reaction to the message with
the same emoji, the count is incremented.

Old messages fetched from the server contain reactions.
They are displayed (along with title and count) at the bottom
of each message.

When clicking the emoji reaction at the bottom of the message, if the
user has already reacted with that emoji to this message, the reaction
is removed and the count is decremented. Otherwise, a reaction is added
and the count is incremented.

Hovering over the emoji reaction at the bottom of the message displays
a list of users who have reacted with this emoji along with the
emoji name.

Hovering over the emoji reactions at the bottom of the message displays
a button to add a reaction.

Fixes #541.
2016-12-30 21:42:54 -08:00