zulip/static/js
Steve Howell bb3ecb178a Fix bugs related to batching message events.
This is general fix that makes sure that we
apply all message-modifying events after we
apply the events for the initial incoming
messages.

The particular scenario that was reported here
was when you would have two tabs for Zulip,
with one of them open and in a PM view, and
with the open tab being at the bottom of the
feed, such that incoming messages would be
immediately visible.

Now suppose the other person in that PM
conversation sent you a message.

The open tab would properly immediately
mark the message as read, and notify
the server.  The problem was that the closed
tab would not process the main message event
until it "woke up", by which time the flag-update
event was bundled into the same event batch
as the main message event.  We'd then process
the flag-update first, which essentially was
a noop, since the actual message wasn't in
the message store yet.  The user would then
see unread counts increment in the closed tab,
while the open tab didn't increment.  This
was confusing.

Now `server_events.js` processes the actual
message first and does the flag-update as part of a
`post_message_events` loop.

We include events for updating message flags,
deleting messages, and attaching submessages
to messages in the `post_message_events` array.

This bug was a bit difficult to simulate in a dev
environment, since you needed your "open" tab
to be in focus to simulate the race, but as
soon as you tab to another place to deliver
a message (whether from the browser or otherwise),
the open tab is no longer in focus.

I did this in the console of my "open"
tab to work around it:

    unread_ops.process_visible = unread_ops.mark_current_list_as_read;

This problem was easy to reproduce, but it wasn't
entirely consistent.  I often needed to send
several messages in succession to trigger event
batching and force the race condition.  (This wasn't
precisely a "race", as events actually arrive in the
correct order; it was having them arrive in the same
batch that triggered the bug.)
2018-08-26 22:26:28 -07:00
..
bundles frontend: Create data structure for starred messages. 2018-08-21 13:42:23 -07:00
portico desktop: Update desktop app to v2.3.5. 2018-08-03 10:19:33 -07:00
stats eslint: Enable `conditionalAssign` config of no-trailing-spaces rule. 2018-06-11 07:51:24 -04:00
.eslintrc.json Change name of eslintrc file to .eslintrc.json 2016-11-29 08:58:39 -08:00
activity.js refactor: Move huddle_with_uri to hash_util. 2018-08-04 09:32:27 -07:00
admin.js settings: Fix color styling for nested inputs to work in night mode. 2018-08-08 11:29:48 -07:00
admin_sections.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
alert_words.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
alert_words_ui.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
archive.js eslint: Enable `no-extra-parens` rule. 2018-06-11 07:51:24 -04:00
attachments_ui.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
avatar.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
blueslip.js Change ui check to ui_report in blueslip. 2018-08-03 15:59:10 -07:00
bot_data.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
buddy_data.js refactor: Move pm_with_uri to hash_util. 2018-08-04 09:32:27 -07:00
buddy_list.js buddy list: Add padding to progressive scrollings. 2018-08-02 16:59:27 -07:00
channel.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
click_handlers.js compose: Do not close compose box on click if parent/itself contains "a". 2018-08-09 17:51:40 -07:00
colorspace.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
common.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
components.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
compose.js compose.js: Move set rtl logic to keyup event. 2018-08-14 11:41:53 -07:00
compose_actions.js refactor: Extract reload_state module. 2018-08-04 13:55:02 +00:00
compose_fade.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
compose_pm_pill.js pills: Use `widget` instead of `my_pill` throughout the app. 2018-07-23 11:29:10 -07:00
compose_state.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
compose_ui.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
composebox_typeahead.js typeahead: Move displaced comment to correct location. 2018-08-20 12:44:24 -07:00
condense.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
copy_and_paste.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
debug.js eslint: Enable `no-extra-parens` rule. 2018-06-11 07:51:24 -04:00
dict.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
drafts.js drafts: Don't save drafts with 2 or less characters. 2018-08-22 16:52:18 -07:00
echo.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
emoji.js build_emoji: Change emoji sprite sheets to use hyphens in names. 2018-08-26 22:16:23 -07:00
emoji_picker.js refactor: Move list of frequent emojis to emoji.js. 2018-08-04 07:59:42 -07:00
favicon.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
feature_flags.js Remove feature_flags.mark_read_at_bottom. 2018-07-07 10:19:15 +02:00
fenced_code.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
fetch_status.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
filter.js refactor: Use early-exits in can_apply_locally(). 2018-07-11 20:00:56 +05:30
floating_recipient_bar.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
gear_menu.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
hash_util.js hash_util: Remove unnecessary parameter is_absolute_url. 2018-08-04 17:56:02 -07:00
hashchange.js refactor: Move operators_to_hash to hash_utils. 2018-08-04 09:32:27 -07:00
hotkey.js Revert "hotkey: Add hotkey to narrow to starred messages." 2018-08-13 15:05:36 -07:00
hotspots.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
info_overlay.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
input_pill.js minor: Avoid code duplication in input_pill. 2018-08-24 10:00:04 -07:00
integration_bot_widget.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
invite.js invite user: Fix click handler called multiple time on submit. 2018-08-26 22:15:50 -07:00
keydown_util.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
lightbox.js thumbnails: Rename data-original to data-src-fullsize. 2018-07-30 13:00:23 -07:00
lightbox_canvas.js lightbox: Make `v` close the lightbox during Pan & Zoom. 2018-07-23 10:36:48 -07:00
list_cursor.js list_cursor: Promote error handling code. 2018-08-24 10:00:04 -07:00
list_render.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
list_util.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
loading.js org settings: Fix a bug where the loading spinner was not visible. 2018-08-08 10:59:23 -07:00
local_message.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
localstorage.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
markdown.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
message_edit.js compose.js: Move set rtl logic to keyup event. 2018-08-14 11:41:53 -07:00
message_events.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
message_fetch.js left sidebar: Make sure the selected stream is visible in left sidebar. 2018-07-23 10:32:10 -07:00
message_flags.js frontend: Create data structure for starred messages. 2018-08-21 13:42:23 -07:00
message_list.js recipient_row.handlebars: Upgrade to font-awesome 4.7 icon prefixes. 2018-07-11 20:31:17 +05:30
message_list_data.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
message_list_view.js Move stream-related uri helpers to hash_util. 2018-08-04 09:32:27 -07:00
message_live_update.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
message_scroll.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
message_store.js Use topic_data.js for topic typeaheads. 2018-07-23 16:08:24 -07:00
message_util.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
message_viewport.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
muting.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
muting_ui.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
narrow.js compose: Update the `New topic` button to `New stream message` in PMs. 2018-08-09 08:55:01 -07:00
narrow_state.js Add narrow_state.is_reading_mode(). 2018-07-10 14:20:24 +05:30
navigate.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
night_mode.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
notifications.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
overlays.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
padded_widget.js buddy list: Add padding to progressive scrollings. 2018-08-02 16:59:27 -07:00
panels.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
people.js refactor: Extract reload_state module. 2018-08-04 13:55:02 +00:00
pm_conversations.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
pm_list.js refactor: Move pm_with_uri to hash_util. 2018-08-04 09:32:27 -07:00
pointer.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
popovers.js user profile popover: Display user pills in custom user field. 2018-08-21 12:10:35 -07:00
presence.js refactor: Extract reload_state module. 2018-08-04 13:55:02 +00:00
reactions.js reactions: Fix minor formatting in log message. 2018-07-10 16:22:52 -04:00
realm_icon.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
recent_senders.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
reload.js refactor: Extract reload_state module. 2018-08-04 13:55:02 +00:00
reload_state.js refactor: Extract reload_state module. 2018-08-04 13:55:02 +00:00
reminder.js hash_util: Remove unnecessary parameter is_absolute_url. 2018-08-04 17:56:02 -07:00
resize.js buddy list: Introduce buddy_list_wrapper div. 2018-08-02 16:56:50 -07:00
rows.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
rtl.js rtl.js: Fix support for supplementary planes of unicode characters (>= U+10000). 2018-08-14 11:39:29 -07:00
schema.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
scroll_bar.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
scroll_util.js scroll_util: Account for element padding in height calculations. 2018-07-27 09:09:52 -07:00
search.js search pills: Backspace should remove a search pill with typeahead open. 2018-07-30 14:33:06 -07:00
search_pill.js search: Add a basic implementation of search pills. 2018-07-23 11:29:10 -07:00
search_pill_widget.js pills: Use `widget` instead of `my_pill` throughout the app. 2018-07-23 11:29:10 -07:00
search_suggestion.js search: Do not display `All messages` suggestion if bar not empty. 2018-07-23 11:29:10 -07:00
search_util.js Extract search_util.js module. 2018-07-30 11:25:32 -07:00
sent_messages.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
server_events.js Fix bugs related to batching message events. 2018-08-26 22:26:28 -07:00
server_events_dispatch.js minor: Alphabetize cases for event dispatching. 2018-08-26 22:26:28 -07:00
settings.js display settings: Implement UI for starred_message_counts. 2018-08-21 13:42:23 -07:00
settings_account.js static/js/settings_account.js: Handle null custom fields values. 2018-08-22 22:45:08 -07:00
settings_bots.js org settings: Use people.get_active_human_persons to get active humans. 2018-07-30 13:48:36 -07:00
settings_display.js build_emoji: Change sprite CSS files to use hyphens in names. 2018-08-26 22:16:23 -07:00
settings_emoji.js emoji: Remove `display_url` from the context of `admin_emoji_list`. 2018-08-14 12:07:56 -07:00
settings_filters.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
settings_invites.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
settings_muting.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
settings_notifications.js models: Rename Realm.show_digest_email field. 2018-08-01 11:05:58 -07:00
settings_org.js org settings: Remove redundant lines for disabling non-existent checkbox. 2018-08-23 11:52:59 -07:00
settings_panel_menu.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
settings_profile_fields.js settings: Fix an error for non-admins on the custom profile fields page. 2018-08-23 23:03:59 -07:00
settings_sections.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
settings_streams.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
settings_toggle.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
settings_ui.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
settings_user_groups.js user pills: Rename class `notmem` to `not-editable` for generalization. 2018-08-21 11:50:01 -07:00
settings_users.js settings_users: Change users "Make admin" button to dropdown. 2018-08-02 15:55:50 -07:00
setup.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
socket.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
starred_messages.js display settings: Implement UI for starred_message_counts. 2018-08-21 13:42:23 -07:00
stream_color.js search: Disable tab_bar due to addition of search pills. 2018-07-23 11:29:10 -07:00
stream_create.js create stream: Remove unnecessary call of `update_announce_stream_state`. 2018-08-08 11:54:28 -07:00
stream_data.js default stream: Limit private streams in default stream suggestions. 2018-08-07 13:29:17 -07:00
stream_edit.js stream settings: Fix hide change-sub-type when admin unsubscribe stream. 2018-08-13 12:14:01 -07:00
stream_events.js refactor: Break subs dependency in stream_data. 2018-08-04 14:06:19 -07:00
stream_list.js Move stream-related uri helpers to hash_util. 2018-08-04 09:32:27 -07:00
stream_muting.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
stream_popover.js subs: Fix bug with narrow_to_row callback in subs modal. 2018-08-01 10:14:09 -07:00
stream_sort.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
submessage.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
subs.js stream settings: Display nothing-selected when active-stream is deleted. 2018-08-07 13:30:53 -07:00
tab_bar.js refactor: Move operators_to_hash to hash_utils. 2018-08-04 09:32:27 -07:00
templates.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
tictactoe_widget.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
timerender.js user profile popover: Rename user last seen. 2018-08-21 11:42:59 -07:00
todo_widget.js widgets: Add todo widget. 2018-07-10 11:18:05 +05:30
top_left_corner.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
topic_data.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
topic_generator.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
topic_list.js Move stream-related uri helpers to hash_util. 2018-08-04 09:32:27 -07:00
translations.js i18n: Fix reference error for localstorage. 2018-05-30 23:28:21 +05:30
transmit.js refactor: Extract reload_state module. 2018-08-04 13:55:02 +00:00
tutorial.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
typeahead_helper.js refactor: Move list of frequent emojis to emoji.js. 2018-08-04 07:59:42 -07:00
typing.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
typing_data.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
typing_events.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
typing_status.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
ui.js ui: Rename update_starred to update_starred_view. 2018-08-01 11:07:44 -07:00
ui_init.js frontend: Create data structure for starred messages. 2018-08-21 13:42:23 -07:00
ui_report.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
ui_util.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
unread.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
unread_ops.js Remove feature_flags.mark_read_at_bottom. 2018-07-07 10:19:15 +02:00
unread_ui.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
upload.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
upload_widget.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
user_events.js settings_users: Update admin_icon with admin change event. 2018-08-02 15:55:50 -07:00
user_groups.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
user_pill.js typeahead: Replace `no-break space (U+00A0)` in query with `space (U+0020)`. 2018-07-25 14:55:11 -07:00
user_search.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
util.js Break emoji_picker dependency inside util.js. 2018-08-04 07:59:42 -07:00
voting_widget.js voting_widget: Don't update question in question.outbound function. 2018-07-06 11:30:12 -04:00
widgetize.js widgets: Add todo widget. 2018-07-10 11:18:05 +05:30
zcommand.js zcommand: Add light/dark mode command aliases for day/night mode. 2018-07-31 07:12:31 -04:00
zform.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00
zulip.js app: Prepare JS files for consumption by webpack. 2018-07-05 10:53:36 +02:00