Commit Graph

664 Commits

Author SHA1 Message Date
Jessica McKellar 636a5f13e1 JS: Switch from Humbug to Zulip in user-visible text.
(imported from commit 968d4f4ac84a6612492d8d063ede7dab5a2c5786)
2013-07-15 17:38:18 -04:00
Tim Abbott 5fc6fb5896 Include a link button after the subject when it matches a realm filter.
This way if you refer to "trac #253" in the subject, it's super
convenient to get from your recipient bar to the ticket.

A note on performance: this part of rendering for 1000 messages takes
about 3.5ms for messages with 1 match; this is small compared to the
overall time for to_dict_uncached for that many message objects, so I
think this is OK for now.

(imported from commit 5bdc2b8415d7599d59eb554739f545c485b78d5a)
2013-07-15 10:41:13 -04:00
Scott Feeney ffa8541818 Remove vestigial parts of old minify code
(imported from commit 692e292528a1697687f1b3024c58371b2cf9b5c9)
2013-07-12 11:59:11 -04:00
Scott Feeney 4313f2ff1e Set initial user presences in O(n), not O(n²) time
Previous code iteratively called set_user_status() once for each user;
which in turn was rerendering the user sidebar, also once for each user.

I changed the API a bit by replacing activity.set_user_status() with
activity.set_user_statuses(), plural, that takes an object and updates
all the user statuses in one go before rendering.

(imported from commit 1111c9029264f892f25e76d2e5e5ff996dcbc7ca)
2013-07-11 16:48:29 -04:00
Leo Franchi 3525b88fa1 Add messages to all our message lists before calculating unread
(imported from commit e216246a045a3ed2de43076e89eb99648c8bac56)
2013-07-11 15:06:32 -04:00
Kevin Mehall 8df4857524 Revert to old mark as unread on view behavior.
Effectively reverts 185e865 and b67e52d.

(imported from commit e9b95f1fd9e2ab7926f15910044e9e9879ea085f)
2013-07-11 14:01:26 -04:00
Tim Abbott ce365829f1 Fix traceback checking for new messages on empty narrows.
(imported from commit da0ba189f23fecdee376066db956e1320bca4deb)
2013-07-09 17:43:46 -04:00
Tim Abbott 641377e7e0 Add messages at bottom when message list is empty.
(imported from commit d15ff7ddb39e30ca08dd9d0eccf3dae75414a3ef)
2013-07-08 17:32:18 -04:00
Tim Abbott bdaacc5393 Don't call msg_list.append/prepend with empty arguments lists.
This can cause unnecessary work to be done.

(imported from commit a33d69598531b6a99520f92cbbac1fdb7eb9ee49)
2013-07-08 17:32:17 -04:00
Tim Abbott a158ee233a message_list: Preserve the scroll position when prepending.
Previously, we had some ugly complicated logic through which we
attempted to keep the selected message on screen when prepending
messages, but we didn't actually preserve the scroll position -- the
selected message would jump on the screen.  This fixes that, by just
saving/restoring the scroll position of the selected message.

This perhaps makes our model/view split even less clear, but at least
it's correct.

(imported from commit 0a01450bbbcdf1b45c891d0570c9fcfb11769315)
2013-07-08 17:32:17 -04:00
Tim Abbott f48097b609 recenter_view: Always place the initial pointer at the center.
It turns out that this code tries to place the initial pointer 1/7
from the top; the only reason something reasonable happened
historically is that bottom_whitespace was only 40% of the screen, so
the pointer message ends up landing in the center anyway.

(imported from commit 56d4c2acd018d9a87551c82a43c214c6d80bfb90)
2013-07-08 17:32:17 -04:00
Tim Abbott f10d3d5517 Only autoscroll for messages that arrived via get_updates.
Previously we incorrectly would sometimes trigger autoscroll when
messages arrived via get_old_messages (i.e. we loaded some historical
messages from the server).  This resulted in some confusing and
erroneous scrolling behavior.

I kinda hate the fact that we need to pass these values all the way
through the rendering process, but fundamentally there's no other way
for _render to find out, and pushing the autoscrolling higher up in
the stack is hard since we don't return anything like the block of new
messages.

(imported from commit c5ed27f1b21691a21c68ed7e09cff8e3e4a75e76)
2013-07-08 17:32:17 -04:00
Steve Howell 465728da37 Move functions inside zephyr.js (cosmetic).
This is purely cosmetic, and just puts some similar functions
together in a way that JS lint won't complain about calling a
function before it was defined.

(imported from commit 8a5a81ae5b7ca7dbaa60147ae4f32f50b1cbbf3a)
2013-07-08 17:12:32 -04:00
Steve Howell 01d96ee7fb Mark messages as read when beginning a reply.
(imported from commit 9743e044dbb7570edcb341ca726369a673fc3db9)
2013-07-08 17:12:32 -04:00
Steve Howell 249252f700 Put spaces after "function" in JS code (cosmetic).
(imported from commit 7579547bfed70b3e53122109d0d6f30ea01f5ac3)
2013-07-05 16:32:32 -04:00
Kevin Mehall 49e3ba7cb3 Make sure a message is in the list before trying to select it.
Fixes the JS traceback "Selected message id not in MessageList"
introduced by b67e52d

Testing:
  * Narrow to a subject and send a PM
  * Narrow to a PM recipient and send a stream message
  * Narrow to a subject and send a stream message to a different subject

(imported from commit 1171c3f97813dc7db891042906762be8afb2a1b5)
2013-07-05 11:26:18 -04:00
Kevin Mehall 56bd11fa7f Don't mark messages read when the pointer lands on them when narrowing.
This is slightly inconsistent, but keeps the unread count from decreasing
when narrowing and un-narrowing.

(imported from commit 185e8653c31a312c166e784b335ae7ae7e9b78e9)
2013-07-03 17:10:15 -04:00
Kevin Mehall 0f6bdafea3 Mark all messages in view as read when you hit the bottom.
Trac #1428

(imported from commit f40d890091528969ae4e4db80adb019cbce60fef)
2013-07-03 17:10:15 -04:00
Kevin Mehall 22c1a66da8 Don't mark messages as read by visibility.
Trac #1428

(imported from commit b67e52d7434220e397ca20ffa49915de6633519c)
2013-07-03 17:10:15 -04:00
Kevin Mehall 318d66ed9e Apply CSS class .unread to unread message rows.
Trac #1428

(imported from commit e19d75ecd6164b9643411b4740a10527952acc0c)
2013-07-03 17:10:15 -04:00
Jessica McKellar 14e27e7583 Add the new tutorial steps.
(imported from commit 9269acbcf58332002b1d45c0134ccb2db980f05c)
2013-07-02 18:26:17 -04:00
Jessica McKellar 5688ee5e57 Provide a function to set the get_updates timeout to 0 for the tutorial.
(imported from commit c904360ffe6fe3cacc9de37d523501a0d45f7176)
2013-07-02 18:26:17 -04:00
Jessica McKellar 672a2ef9ac get_updates: factor out success work into a function.
It has ballooned to screenfuls of code, and this refactor will help
with the tutorial.

(imported from commit 05d18558911ee7ce58b0de43eedf164b495d47ae)
2013-07-02 18:26:17 -04:00
Tim Abbott f473cb5fbe Use bulk operations in notify_subscription_{added_removed}.
After fixing the high numbers of database queries earlier in this
branch, I found that sending 500 RabbitMQ messages for a bulk change
in subscriptions was consuming more than half the time for these (and
then we'd end up with 500 events in a queue).  To handle this, we
create a "user X subscribed to these N streams" event, rather than
sending one event for each individual subscription.

(imported from commit 44a34a9fab9b67e9f0da6fee53335d8c5030392b)
2013-07-02 10:50:29 -04:00
Kevin Mehall 371b3827d2 Show unread subjects in stream sidebar.
Trac #1403.

This shows the 5 most recent subjects, as well as any others with unread messages. This
requires tracking all subjects and filtering at display time, rather than filtering when
building the subject list.

(imported from commit 8bda7d50e6785a6e70abea4b3af4d03a16d076d3)
2013-07-01 13:35:00 -04:00
Jessica McKellar 05bbfb42a9 Make bankrupting more resilient against regular pointer updates being in flight.
(imported from commit 90e1dc16e7d3295b6ed3f5993fe82ac4fcd2d7cc)
2013-06-21 11:00:44 -04:00
Jessica McKellar 24b41351a6 Clean up the message we display while bankrupting you.
(imported from commit 007c97eded421a021cd6aefb7f38fe8f4946b26c)
2013-06-21 11:00:44 -04:00
Jessica McKellar 30ab99d765 Offer to bankrupt a user if they are way behind.
(imported from commit 5483bb548a55e6cbf788b71a8885b3c990b94b77)
2013-06-21 11:00:43 -04:00
Leo Franchi 468bbf216d Add a new window.bridge call for unread pms
(imported from commit 098c31dbd69c4c020e4c093095e4c78723db0bb1)
2013-06-20 16:23:30 -04:00
Kevin Mehall 9322e63d32 Refactor typeahead for user names (PM and @reply).
Get data directly from the main user list, rather than maintaining a
separate list just for autocomplete.

Fixes trac #1362 -- Does not depend on historical messages, so
will do the correct autocomplete after a single reload.

(imported from commit 6b35a709dba3384530082e8cfacf0151f9e0eb26)
2013-06-18 17:52:39 -04:00
Zev Benjamin 08097d6788 Don't always claim that the application has been updated when reloading
I don't love the default reloading message, but I'm not sure how to
tell the user why we need to reload in several cases.

(imported from commit 5f2eecdb0d83f31bd60673b247e8aac8f08ce20f)
2013-06-18 16:36:02 -04:00
Zev Benjamin eb62a31bb8 Use a different error message for get_events and get_old_messages
(imported from commit 191f46b482d0bf4adf60967cdfebb0d7dbcf82f8)
2013-06-18 16:36:02 -04:00
Steve Howell a46a371677 DRY up sent-by-me checks with messages.sent_by_me.
This is a pure refactoring.  We set messages.sent_by_me inside
add_message_metadata(), which gets called early in a message's
lifetime.

(imported from commit 2f6270f92ecdf0e4a64401030f86d89a8fb7be2e)
2013-06-18 16:01:09 -04:00
Tim Abbott c824901e2e Load fewer messages from the server when narrowing.
This should substantially improve narrowing performance, while still
delivering enough messages that one should only need to contact the
server again if the user scrolls up a significant distance.

(imported from commit 2b0af0e5b9d3a449e7f195a87d57d517b47f0b3a)
2013-06-17 13:48:06 -04:00
Leo Franchi 71e14674aa Be more judicious in our showing of errors
Don't show an error banner for any uncaught JS exception, as often the app
will continue to work fine, and there's no way to dismiss it other than
reloading the page.

Also, don't show a transient "could not connect to humbug" error if
the check-for-messages-in-narrow request fails.

(imported from commit 2c634ba088b58c17fa5b2e3353b0589d40b8e357)
2013-06-11 17:33:17 -04:00
acrefoot da361b9208 jbarnold composebox UI experiment
1) When you send a message, restore the focus to the composebox, targeted at the same recipient
2) If the composebox is completely empty and you press up or down, have that close the composebox and take the appropriate action
3) If you started the compose via a reply option (r, enter, click), don't refocus the composebox if the cursor has changed.

(imported from commit 84545e49d06959eb62e7fd2b22e1387383df6d1d)
2013-06-07 17:39:31 -04:00
Steve Howell 1cd113db10 Move message_viewport_info() from ui.js to viewport.js
The message_viewport_info() function encapsulates our logic
around the compose box and other elements blocking the viewport,
so viewport.js seems like a more logical home for it.  It also
makes ui.js, one of our largest modules, a little bit smaller.

(imported from commit 7838668b28175e161b87a6d7a8124b73012f0ff3)
2013-06-06 11:59:45 -04:00
Steve Howell 5a826040d8 Clean up code for unread counts and notifications.
The core simplification here is that zephyr.js no longer has:

  * the global home_unread_messages
  * the function unread_in_current_view() [which used the global]

The logic that used to be in zephyr is now in its proper home
of unread.js, which has these changes:

  * the structure returned from unread.get_counts() includes
    a new member called unread_in_current_view
  * there's a helper function unread.num_unread_current_messages()

Deprecating zephyr.unread_in_current_view() affected two callers:

 * notifications.update_title_count()
 * notifications_bar.update()

The above functions used to call back to zephyr to get counts, but
there was no nice way to enforce that they were getting counts
at the right time in the code flow, because they depended on
functions like process_visible_unread_messages() to orchestrate
updating internal unread counts before pushing out counts to the DOM.

Now both of those function take a parameter with the unread count,
and we then had to change all of their callers appropriately. This
went hand in hand with another goal, which is that we want all the
unread-counts logic to funnel though basically one place, which
is zephyr.update_unread_counts().  So now that function always
calls notifications_bar.update() [NEW] as well as calling into
the modules unread.js, stream_list.js, and notifications.js [OLD].

Adding the call to notifications_bar.update() in update_unread_counts()
made it so that some other places in the code no longer needed to call
notifications_bar.update(), so you'll see some lines of code
removed.  There are also cases where notifications.update_title_count()
was called redundantly, since the callers were already reaching
update_unread_counts() via other calls.

Finally, in ui.resizehandler, you'll see a simple case where the call
to notifications_bar.update() is preceded by an explicit call
to unread.get_counts().

(imported from commit ce84b9c8076c1f9bb20a61209913f0cb0dae098c)
2013-06-05 17:47:34 -04:00
Steve Howell 8be0ea972a Cosmetic: move function up in file.
This just moves keep_pointer_in_view() to be adjacent to recenter_view()
in the file.

(imported from commit 27056e2a949ffef262ac21130436f7303fd2935f)
2013-06-05 13:50:02 -04:00
Steve Howell 042cd8f222 Handle large/gigantic messages when recentering.
(imported from commit d57e702f504a9a3e6b7049a19217671902df4ab7)
2013-06-05 13:50:01 -04:00
Steve Howell 4c8a293750 Scroll more like barnowl again. (but closer to the edges)
We are moving back to a barnowl-ish scrolling algorithm for
the arrow keys, where when you have a message selected toward
the bottom of the screen, hitting down arrow and up arrow
effectively puts the originally selected message at the center
of the screen.  In order to avoid unnecessary scrolls, we
are making it so that you can move the pointer closer to the
edges.

(imported from commit c08233d6d2034a04469b8f424b39d94a230cafe0)
2013-06-05 13:50:01 -04:00
Zev Benjamin d95ea89f54 Fix a "can't read property 'id' of undefined" user error
`current_msg_list.get(id)` and `rows.get(id,
current_msg_list.table_name)` are not interchangable in terms of
checking for whether we have a message.  The former checks whether
the message is in the current message list while the latter checks
whether the message is in the current message list and currently
rendered.  `message_edit.end` only operates on rendered messages.

(imported from commit 203ee612bfd0aa94571dde9b601e948b3c6f6cbb)
2013-06-04 15:39:51 -04:00
Zev Benjamin 6bd61f458d Don't throw an exception if someone edits a very old message
Previously, if you didn't have a message that someone else had edited
in your message list, you would get an exception because we weren't
checking whether we actually had the message or not.

(imported from commit 33a5c6e7fe95b5397a32df5c7b5f6714d71e1e5f)
2013-06-04 15:38:42 -04:00
Steve Howell 3ee4161ace Allow pointer in more places.
Before this fix, the code would restrict the pointer to be above
either the 1/2 mark or 2/3 mark of the page, depending on your
scrolling direction.  This fix makes it so that the system leaves
your scroll and pointer alone when between the 1/5 mark and 4/5
mark.  This means the user can read more messages on the screen
at a time before getting paginated.

(imported from commit 98f6319bf63181dd331e037ac20a0c15518725ea)
2013-06-03 11:04:01 -04:00
acrefoot 6ae117ea5f Re-focus on the compose box after a send, auto-move cursor
Re-focuses on the compose box after a send, under these conditions:
1) narrowed to stream+subject -or- responding to PM/huddle
2) compose was initiated by clicking on a message or hitting "r"/"enter"
3) cursor has not moved since you've started the composition

Additionally, if you are thus narrowed, we will move your cursor when you've sent
a message to that message, assuming that such a message initially appears visible.

(imported from commit 373c858081694e6fc9994639340a847d66edb566)
2013-05-31 13:43:05 -04:00
Steve Howell 66b93d5cfd Fix barnowl style scrolling w/r/t fixed elements.
This change fixes the barnowl scrolling so that the ratios of
1/5, 1/2, and 2/3 are all relative to the visible viewport.

The core part of the fix is that we need to call
ui.message_viewport_info() to get the correct offsets for
the top/height of the actually visible viewport  Because
this function is fairly expensive, I didn't want the
helper functions needlessly re-calling it.  I could
have passed the helper functions the structure, but at
that point it was simpler to inline their functionality.

(imported from commit fb10d99313d568e85acfa70703c4651466acbc21)
2013-05-31 12:51:50 -04:00
Leo Franchi 56af48cd50 Split wildcard mentions from personal mentions, only email on personals
(imported from commit 18971d9e40dd2c93ef9c30edc963da33e3c65309)
2013-05-31 12:24:31 -04:00
Steve Howell 3f1b3af002 Add "Mentioning messages" to the upper left sidebar.
Treat "mentioned" messages like "starred" messages for narrowing.

Lots of ugly copy/paste here.  There might be opportunity for
some cleanup in places.

(imported from commit e7629890d42643c0000e1cc85422b2a0690f2cc4)
2013-05-30 14:45:01 -04:00
Keegan McAllister 371d0dbaa0 Identify app.js source map using a special comment
If we're going to minify third party code, the size heuristic may not hold
anymore.

(imported from commit 78ada1fee1446e78b3b1ad299ee3e975d1cd9002)
2013-05-30 13:51:46 -04:00
acrefoot c58ac9cc0c Re-focus on the compose box after a send
Re-focuses on the compose box after a send, but only if
the compose-box was opened by responding to the message
at the cursor (by hitting "r", enter, or clicking on the message)

(imported from commit 8e7560c8ea31397b57b2bc3e2e7d9dd996226a6f)
2013-05-29 13:07:45 -04:00