zulip/static/js
Steve Howell f59cca2dcd reactions: Rewrite code to use clean reactions.
Before this commit, the reactions code would
take the `message.reactions` structure from
the server and try to "collapse" all the reactions
for the same users into the same reactions,
but with each reaction having a list of user_ids.
It was a strangely denormalized structure that
was awkward to work with, and it made it really
hard to reason about whether the data was in
the original structure that the server sent or
the modified structure.

Now we use a cleaner, normalized Map to keep
each reaction (i.e. one per emoji), and we
write that to `message.clean_reactions`.

The `clean_reactions` structure is now the
authoritatize source for all reaction-related
operations.  As soon as you try to do anything
with reactions, we build the `clean_reactions`
data on the fly from the server data.

In particular, when we process events, we just
directly manipulate the `clean_reactions` data,
which is much easier to work with, since it's
a Map and doesn't duplicate any data.

This rewrite should avoid some obscure bugs.

I use `r` as shorthand for the clean reaction
structures, so as not to confuse it with
data from the server's message.reactions.

It also avoids some confusion where we use
`reaction` as a var name for the reaction
elements.
2020-03-23 17:30:18 -04:00
..
analytics js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
billing js: Convert _.contains(a, …) to a.includes(…). 2020-02-10 14:08:12 -08:00
bundles i18n: Rename translations.js to i18n.js. 2020-02-29 12:19:51 -08:00
portico apps: Fix broken desktop download links. 2020-03-10 14:38:23 -07:00
stats stats: Fix Other calculation. 2020-03-02 17:45:44 -08:00
types dependencies: Upgrade stacktrace-gps from 3.0.3 to 3.0.4. 2020-02-04 22:13:33 -08:00
activity.js dict: Replace with Map. 2020-02-25 15:37:37 -08:00
admin.js refactor: Extract settings_data.py. 2020-02-28 17:11:24 -08:00
alert_words.js refactor: Clean up alert_words API. 2020-02-27 11:10:13 -08:00
alert_words_ui.js refactor: Clean up alert_words API. 2020-02-27 11:10:13 -08:00
archive.js js: Use modern spread arguments syntax. 2020-02-11 17:43:35 -08:00
attachments_ui.js js: Convert a.indexOf(…) !== -1 to a.includes(…). 2020-02-10 14:08:12 -08:00
avatar.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
blueslip.js js: Convert _.extend to spread syntax or Object.assign. 2020-02-25 14:09:39 -08:00
blueslip_stacktrace.ts dependencies: Upgrade stacktrace-gps from 3.0.3 to 3.0.4. 2020-02-04 22:13:33 -08:00
bot_data.js ui_init: Handle page_params more cleanly. 2020-02-26 13:14:09 -08:00
buddy_data.js util.js: Remove util from window. 2020-02-15 12:20:20 -08:00
buddy_list.js js: Automatically convert _.each to for…of. 2020-02-07 14:09:47 -08:00
channel.js channel: Ignore error responses when reloading too. 2020-02-27 17:41:45 -08:00
click_handlers.js util.js: Remove util from window. 2020-02-15 12:20:20 -08:00
color_data.js js: Convert _.pluck(a, "key") to item => item.key. 2020-02-27 17:20:34 -08:00
colorspace.js zjsunit: Use assert in strict mode. 2020-02-12 08:16:26 -05:00
common.js common: Account for string.match returning null. 2020-02-13 16:37:52 -08:00
components.js js: Convert _.find(a, …) to a.find(…). 2020-02-10 14:08:12 -08:00
compose.js util: Replace util.set_message_topic(). 2020-02-21 09:53:45 -05:00
compose_actions.js js: Convert _.extend to spread syntax or Object.assign. 2020-02-25 14:09:39 -08:00
compose_fade.js util.js: Remove util from window. 2020-02-15 12:20:20 -08:00
compose_pm_pill.js util.js: Remove util from window. 2020-02-15 12:20:20 -08:00
compose_state.js util: Kill off rtrim() helper. 2020-02-15 12:20:20 -08:00
compose_ui.js js: Convert _.map(a, …) to a.map(…). 2020-02-10 14:08:12 -08:00
composebox_typeahead.js Rename get_realm_persons() to get_realm_users(). 2020-03-22 10:55:11 -07:00
condense.js int_dict: Replace with Map. 2020-02-25 15:37:37 -08:00
confirm_dialog.js js: Automatically convert _.each to for…of. 2020-02-07 14:09:47 -08:00
copy_and_paste.js upload: Replace jQuery filedrop with Uppy. 2020-02-13 16:43:19 -08:00
csrf.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
debug.js js: Cleanup debug.js example to use ES syntax. 2020-03-09 14:07:13 -07:00
drafts.js util.js: Remove util from window. 2020-02-15 12:20:20 -08:00
echo.js js: Convert $.extend to spread syntax. 2020-02-25 14:09:39 -08:00
emoji.js emoji: Resolve emoji sprite sheets and stylesheets through Webpack. 2020-02-25 14:43:46 -08:00
emoji_picker.js reactions: Rewrite code to use clean reactions. 2020-03-23 17:30:18 -04:00
emojisets.js emoji: Resolve emoji sprite sheets and stylesheets through Webpack. 2020-02-25 14:43:46 -08:00
favicon.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
feature_flags.js feature_flags: Remove clicking_notification_causes_narrow. 2020-02-27 11:19:13 -08:00
feedback_widget.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
fenced_code.js util: Kill off rtrim() helper. 2020-02-15 12:20:20 -08:00
fetch_status.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
filter.js filter: Cache value of can_mark_messages_read. 2020-03-17 12:27:08 -07:00
floating_recipient_bar.js js: Convert _.map(a, …) to a.map(…). 2020-02-10 14:08:12 -08:00
fold_dict.ts dict: Remove each method. 2020-02-04 12:22:03 -08:00
gear_menu.js gear_menu: Convert scroll_positions from object to Map. 2020-02-12 10:39:01 -08:00
global.d.ts util.js: Remove util from window. 2020-02-15 12:20:20 -08:00
hash_util.js search/hash_util: Parse negated searches properly. 2020-03-22 11:29:02 -07:00
hashchange.js hashchange: Update state.old_hash before returning early. 2020-02-27 11:14:02 -08:00
hbs.d.ts blueslip: Make stack trace more readable. 2019-10-31 13:47:54 -07:00
hotkey.js emoji_codes: Replace JS module with JSON module. 2020-02-12 10:09:12 -08:00
hotspots.js js: Convert _.pluck(a, "key") to item => item.key. 2020-02-27 17:20:34 -08:00
i18n.js i18n: Rename translations.js to i18n.js. 2020-02-29 12:19:51 -08:00
info_overlay.js js: Convert _.map(a, …) to a.map(…). 2020-02-10 14:08:12 -08:00
input_pill.js js: Convert _.pluck(a, "key") to item => item.key. 2020-02-27 17:20:34 -08:00
integration_bot_widget.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
invite.js invitations: Avoid adding to notifications stream unconditionally. 2020-01-27 15:36:59 -08:00
keydown_util.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
lazy_set.js dict, lazy_set: Return an iterator from keys method. 2020-02-04 12:22:03 -08:00
lightbox.js minor: Fix blueslip error to use zid. 2020-02-24 12:19:10 -08:00
lightbox_canvas.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
list_cursor.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
list_render.js ui: Fix list_render sorting breaking after re-creation/update. 2020-03-17 12:08:02 -07:00
list_util.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
loading.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
local_message.js local_message: Convert already_used from object to Set. 2020-02-12 10:39:01 -08:00
localstorage.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
markdown.js markdown: Add helper configuration for mobile. 2020-02-18 16:13:38 -08:00
markdown_config.js markdown: Add helper configuration for mobile. 2020-02-18 16:13:38 -08:00
message_edit.js feature_flags: Remove propagate_topic_edits. 2020-02-27 11:19:13 -08:00
message_events.js filters: Refactor filter_with_new_topic to expand its functionality. 2020-03-06 17:10:26 -08:00
message_fetch.js js: Convert remaining _.each(a, …) to a.forEach(…). 2020-02-10 14:08:12 -08:00
message_flags.js js: Convert _.filter(a, …) to a.filter(…). 2020-02-10 14:08:12 -08:00
message_list.js js: Convert _.extend to spread syntax or Object.assign. 2020-02-25 14:09:39 -08:00
message_list_data.js js: Convert _.pluck(a, "key") to item => item.key. 2020-02-27 17:20:34 -08:00
message_list_view.js js: Convert _.extend to spread syntax or Object.assign. 2020-02-25 14:09:39 -08:00
message_live_update.js js: Automatically convert _.each to for…of. 2020-02-07 14:09:47 -08:00
message_scroll.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
message_store.js util: Replace util.get_message_topic(). 2020-02-21 09:53:45 -05:00
message_util.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
message_viewport.js util.js: Remove util from window. 2020-02-15 12:20:20 -08:00
muting.js int_dict: Replace with Map. 2020-02-25 15:37:37 -08:00
muting_ui.js util: Replace util.get_message_topic(). 2020-02-21 09:53:45 -05:00
narrow.js Avoid blueslip error for empty streams. 2020-03-22 11:29:02 -07:00
narrow_state.js dict: Replace with Map. 2020-02-25 15:37:37 -08:00
navigate.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
night_mode.js js: Purge useless IIFEs. 2019-10-25 13:51:21 -07:00
notifications.js feature_flags: Remove clicking_notification_causes_narrow. 2020-02-27 11:19:13 -08:00
overlays.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
padded_widget.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
page_params.js page_params: Record page_params_parse_time. 2020-01-15 12:01:14 -08:00
panels.js panels: Show a banner for users with legacy desktop apps. 2020-02-28 01:54:46 -08:00
people.js Rename people.add_in_realm to people.add(). 2020-03-22 10:55:11 -07:00
pm_conversations.js js: Convert _.pluck(a, "key") to item => item.key. 2020-02-27 17:20:34 -08:00
pm_list.js js: Convert _.contains(a, …) to a.includes(…). 2020-02-10 14:08:12 -08:00
pm_list_dom.js js: Convert _.map(a, …) to a.map(…). 2020-02-10 14:08:12 -08:00
pointer.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
poll_widget.js js: Convert _.any(a, …), _.some(a, …) to a.some(…). 2020-02-10 14:08:12 -08:00
popovers.js refactor: Extract settings_data.py. 2020-02-28 17:11:24 -08:00
presence.js Rename get_realm_persons() to get_realm_users(). 2020-03-22 10:55:11 -07:00
reactions.js reactions: Rewrite code to use clean reactions. 2020-03-23 17:30:18 -04:00
ready.js templates: Make the Loading… message more robust. 2019-09-20 10:34:44 -07:00
realm_icon.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
realm_logo.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
recent_senders.js int_dict: Replace with Map. 2020-02-25 15:37:37 -08:00
reload.js js: Convert _.defaults to spread syntax. 2020-02-25 14:09:39 -08:00
reload_state.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
reminder.js util: Replace util.set_message_topic(). 2020-02-21 09:53:45 -05:00
resize.js util.js: Remove util from window. 2020-02-15 12:20:20 -08:00
rows.js rows.js: Add error handling to rows.id(). 2020-02-24 12:19:10 -08:00
rtl.js util.js: Remove util from window. 2020-02-15 12:20:20 -08:00
schema.js js: Convert _.isString to typeof. 2020-02-10 15:57:20 -08:00
scroll_bar.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
scroll_util.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
search.js search_suggestions: Convert lookup_table from object to Map. 2020-02-12 10:39:01 -08:00
search_pill.js js: Convert _.pluck(a, "key") to item => item.key. 2020-02-27 17:20:34 -08:00
search_pill_widget.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
search_suggestion.js refactor: Extract settings_data.py. 2020-02-28 17:11:24 -08:00
search_util.js js: Convert _.any(a, …), _.some(a, …) to a.some(…). 2020-02-10 14:08:12 -08:00
sent_messages.js sent_messages: Convert messages from object to Map. 2020-02-12 10:39:01 -08:00
server_events.js js: Convert _.extend to spread syntax or Object.assign. 2020-02-25 14:09:39 -08:00
server_events_dispatch.js Rename people.add_in_realm to people.add(). 2020-03-22 10:55:11 -07:00
settings.js refactor: Extract settings_config. 2020-02-21 12:06:31 -08:00
settings_account.js int_dict: Replace with Map. 2020-02-25 15:37:37 -08:00
settings_bots.js minor: Rename function to get_active_humans(). 2020-03-22 10:55:11 -07:00
settings_config.js settings: Add EMAIL_ADDRESS_VISIBILITY_NOBODY. 2020-03-06 16:34:08 -08:00
settings_data.js settings: Add EMAIL_ADDRESS_VISIBILITY_NOBODY. 2020-03-06 16:34:08 -08:00
settings_display.js emoji: Resolve emoji sprite sheets and stylesheets through Webpack. 2020-02-25 14:43:46 -08:00
settings_emoji.js js: Convert a.indexOf(…) !== -1 to a.includes(…). 2020-02-10 14:08:12 -08:00
settings_exports.js js: Convert a.indexOf(…) !== -1 to a.includes(…). 2020-02-10 14:08:12 -08:00
settings_invites.js settings_invites: Convert invited_as_values from object to Map. 2020-02-10 15:57:20 -08:00
settings_linkifiers.js js: Convert a.indexOf(…) !== -1 to a.includes(…). 2020-02-10 14:08:12 -08:00
settings_muting.js js: Clean up stream_id type confusion. 2020-01-16 13:23:47 -08:00
settings_notifications.js js: Automatically convert _.each to for…of. 2020-02-07 14:09:47 -08:00
settings_org.js refactor: Extract settings_data.py. 2020-02-28 17:11:24 -08:00
settings_panel_menu.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
settings_profile_fields.js settings_profile_fields: Iterate over field_types with Object.values. 2020-02-10 14:08:12 -08:00
settings_sections.js dict: Replace with Map. 2020-02-25 15:37:37 -08:00
settings_streams.js int_dict: Replace with Map. 2020-02-25 15:37:37 -08:00
settings_toggle.js js: Automatically convert _.each to for…of. 2020-02-07 14:09:47 -08:00
settings_ui.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
settings_user_groups.js zjsunit: Use assert in strict mode. 2020-02-12 08:16:26 -05:00
settings_users.js minor: Rename function to get_active_humans(). 2020-03-22 10:55:11 -07:00
setup.js util.js: Remove util from window. 2020-02-15 12:20:20 -08:00
starred_messages.js js: Automatically convert _.each to for…of. 2020-02-07 14:09:47 -08:00
stream_color.js js: Convert _.defaults to spread syntax. 2020-02-25 14:09:39 -08:00
stream_create.js refactor: Inline ajaxSubscribeForCreation. 2020-02-18 11:02:14 -08:00
stream_data.js stream edit: Extract stream_data.potential_subscribers(). 2020-03-22 10:55:11 -07:00
stream_edit.js stream edit: Extract stream_data.potential_subscribers(). 2020-03-22 10:55:11 -07:00
stream_events.js js: Automatically convert _.each to for…of. 2020-02-07 14:09:47 -08:00
stream_list.js int_dict: Replace with Map. 2020-02-25 15:37:37 -08:00
stream_muting.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
stream_popover.js Convert more stream_ids to ints. 2020-01-12 11:27:26 -08:00
stream_sort.js util.js: Remove util from window. 2020-02-15 12:20:20 -08:00
stream_ui_updates.js subscriber list: Fix display of email addresses in subscribers list. 2020-03-08 12:42:08 -07:00
submessage.js js: Convert _.find(a, …) to a.find(…). 2020-02-10 14:08:12 -08:00
subs.js subs: Convert hidden_ids from object to Map. 2020-02-12 10:39:01 -08:00
tab_bar.js js: Convert _.map(a, …) to a.map(…). 2020-02-10 14:08:12 -08:00
templates.js js: Use modern spread arguments syntax. 2020-02-11 17:43:35 -08:00
tictactoe_widget.js tictactoe: Fix type confusion. 2020-02-21 20:01:21 -05:00
timerender.js zjsunit: Use assert in strict mode. 2020-02-12 08:16:26 -05:00
todo_widget.js todo_list: Add task description and index numbers. 2020-03-12 08:02:06 -04:00
top_left_corner.js top_left_corner: Don't export `should_expand_pm_list()`. 2020-02-11 14:14:59 -08:00
topic_data.js int_dict: Replace with Map. 2020-02-25 15:37:37 -08:00
topic_generator.js js: Convert _.reject(a, … => …) to a.filter(… => !…). 2020-02-10 14:08:12 -08:00
topic_list.js int_dict: Replace with Map. 2020-02-25 15:37:37 -08:00
topic_list_data.js js: Automatically convert _.each to for…of. 2020-02-07 14:09:47 -08:00
topic_zoom.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
transmit.js util: Replace util.set_message_topic(). 2020-02-21 09:53:45 -05:00
tslint.json
tutorial.js js: Purge useless IIFEs. 2019-10-25 13:51:21 -07:00
typeahead_helper.js refactor: Extract settings_data.py. 2020-02-28 17:11:24 -08:00
typing.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
typing_data.js dict: Replace with Map. 2020-02-25 15:37:37 -08:00
typing_events.js people: Rename method to get_by_user_id(). 2020-02-05 12:04:56 -08:00
ui.js js: Convert a.indexOf(…) !== -1 to a.includes(…). 2020-02-10 14:08:12 -08:00
ui_init.js js: Convert _.pluck(a, "key") to item => item.key. 2020-02-27 17:20:34 -08:00
ui_report.js ui_report: Fix HTML escaping of &. 2020-02-13 17:50:59 -08:00
ui_util.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
unread.js unread: Convert ids.push(...a) to a loop. 2020-02-27 11:06:49 -08:00
unread_ops.js js: Automatically convert _.each to for…of. 2020-02-07 14:09:47 -08:00
unread_ui.js topic list: Use vdom techniques. 2020-02-05 13:04:16 -08:00
upload.js upload: Replace jQuery filedrop with Uppy. 2020-02-13 16:43:19 -08:00
upload_widget.js js: Convert a.indexOf(…) !== -1 to a.includes(…). 2020-02-10 14:08:12 -08:00
user_events.js js: Convert _.has to Object.prototype.hasOwnProperty. 2020-02-25 14:09:39 -08:00
user_groups.js ui_init: Handle page_params more cleanly. 2020-02-26 13:14:09 -08:00
user_pill.js Rename get_realm_persons() to get_realm_users(). 2020-03-22 10:55:11 -07:00
user_search.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00
user_status.js ui_init: Handle page_params more cleanly. 2020-02-26 13:14:09 -08:00
user_status_ui.js user status: Save status on enter keypress. 2020-03-06 17:13:50 -08:00
util.js js: Convert _.extend to spread syntax or Object.assign. 2020-02-25 14:09:39 -08:00
vdom.js vdom: Use _.escape for correct HTML escaping. 2020-02-13 17:50:59 -08:00
widgetize.js widgetize: Convert widget_contents from object to Map. 2020-02-06 17:24:43 -08:00
zcommand.js js: Convert a.indexOf(…) !== -1 to a.includes(…). 2020-02-10 14:08:12 -08:00
zform.js js: Automatically convert _.each to for…of. 2020-02-07 14:09:47 -08:00
zulip.js js: Automatically convert var to let and const in most files. 2019-11-03 12:42:39 -08:00