Commit Graph

596 Commits

Author SHA1 Message Date
Steve Howell 763782a6f0 Isolate stream_list.js's DOM manipulation when updating unread counts.
This refactoring basically splits off two functions from update_unread_counts(),
which then becomes a simple three-liner.

The function get_unread_counts() is extracted, and it's purely functional
computation.  It paves the way for a more pull-based approach to getting "unread"
counts, where other parts of the program can just call it to get values as
needed without worrying about side effects.  It is staying in zephyr.js for
now.

The other function is stream_list.update_dom_with_unread_counts(), which
has a new home in stream_list.js.  It handles all the DOM manipulation
aspect of unread counts in the left pane, mostly by delegating to smaller
functions within stream_list.  Some of those smaller functions can now
be turned into private methods FWIW, but I'm not sure it's worth the
trouble.

(imported from commit 799f9ebbaed8d530829a4741ef14be04bd8abf5a)
2013-05-14 15:21:27 -04:00
Steve Howell f024a7ab14 Call process_loaded_for_unread() more directly.
This is a prefactoring to eventually eliminate the home_unread_messages
global variable.  More commits to follow.

In order to set up process_loaded_for_unread() not to modify
global variable to get its job done, we want to pull it out of
add_messages(), so that add_messages() doesn't have to pass back
state to the 9 different places in the codebase where it's called.
There are only 2 places where process_loaded_for_unread() get
called after this commit.

In order to facilitate pulling up process_loaded_for_unread(), I
made it so that the contract for add_messages() was to accept
already-hydrated messages.  This way I could hydrate the messages
before calling process_loaded_for_unread() without have to
worry about double-caching them in add_messages.  This will
slightly improve performance, but it was mostly done for code
clarity.

(imported from commit ad5aaad5b1f22c31647370f4c9dcb5f89d7d99a7)
2013-05-14 15:21:27 -04:00
Tim Abbott a4c5c24029 Use the event system to sync onboarding steps across browser tabs.
(imported from commit 29311390133aca8f3a3d79fbe06dbbcabc4fb6ea)
2013-05-14 10:27:40 -04:00
Tim Abbott f87e62a8f3 Show unread counts for the home view in the left sidebar.
(imported from commit e56da93c45dff30ae150b0da676bab2278d25718)
2013-05-13 11:58:58 -04:00
Tim Abbott 14feac48e7 All PMs are in the home view.
(imported from commit c5e1a06fe39322f6065f2e56ef00b5f2f0e8aaf0)
2013-05-13 11:58:58 -04:00
Tim Abbott 8f29a39991 Remove the newer_than_pointer_count hack in unread accounting.
This was a workaround for a number of other bugs we had, but at this
point just serves to make debugging more difficult.

(imported from commit 6662b7854c265bd8016f6c8ce75a095731211a45)
2013-05-13 11:58:58 -04:00
Tim Abbott b7e682b157 Fix home view unread counts being 1 lower than they should be.
(imported from commit c9f9a623e862eaf9cb38626318df855ef7bad993)
2013-05-13 11:58:58 -04:00
Tim Abbott 91f8768fb7 Fix private message unread counts never displaying.
(imported from commit fda193ceba36dba2cd7b0694e15d1b927365dc26)
2013-05-13 11:58:58 -04:00
Jessica McKellar c7555c6cf9 Add support for completely collapsing messages through the info popover.
(imported from commit 0a01c4cc8f99019233659c175d73826e16cc95ee)
2013-05-10 18:00:57 -04:00
Leo Franchi 1267ffe542 Show unread counts next to expanded subject names
(imported from commit 6de1145cdec8d7e68395c1f9a7a95cd59136d805)
2013-05-09 10:41:32 -04:00
Tim Abbott 8d6551e37d Send notifications when a message appears offscreen even if focused.
Previously we never sent desktop notifications when the browser was
focused, even if the message appeared offscreen.  After this commit
there are only a few cases when PM or other notifiable message doesn't
trigger a desktop notification:

(1) You sent it yourself
(2) It was onscreen when it arrived while your Humbug window had focus

(imported from commit e381c02c0e6794594d6934f57249a11ba2a88210)
2013-05-09 10:35:49 -04:00
Zev Benjamin 1b5fb31b2c Make viewport a module that caches height and width values
The .height() and .width() functions are actually pretty expensive for
the number of times we call them.  The viewport height and width
don't change often, though, so we can just cache them and recalculate
them on window resize.

(imported from commit 129fb8c058144125e2974f6b7967cd9f1a5c9ead)
2013-05-09 10:35:47 -04:00
Zev Benjamin 4de79cf723 Make within_viewport take the row offset and row height
The .height() and .width() functions are actually pretty expensive
for the number of times we call them.  The callers of within_viewport
already know the offset and height of the row, so we just pass them
in so the values don't have to be recalculated.

(imported from commit d1c077bd87463d695f0bbe337b6a8b04ac2d17ce)
2013-05-09 10:35:47 -04:00
Zev Benjamin 7becd3e504 Move stream sidebar functions to their own module
(imported from commit 50771c1590eb3a0dbb151bf6a798bd14a4418857)
2013-05-09 10:35:46 -04:00
Zev Benjamin 26ea7e0897 Build the recent subjects list on demand
We previously kept the lists in the DOM for all streams and updated
them all when new messages arrived.  This was very expensive for
large numbers of streams, so we now just build the subject lists on
demand.

(imported from commit 937ad4322ce2014200aeae8645f79875f6af576e)
2013-05-07 11:47:13 -04:00
Zev Benjamin beba14a86c Only call add_message_metadata once when receiving messages in a narrowed view
We memoize add_message_metadata by checking if the message is already
in the all_msg_list.  Therefore, we need to add messages to that
message list before we add it to the narrowed_msg_list.

(imported from commit 4346179376ef6f982162c02c6152a0d294bfb2c0)
2013-05-07 11:47:12 -04:00
Leo Franchi 57d5bcf1f8 Only update unread counts if you're subscribed to that stream
(imported from commit 100047ad6ca1818cdf1c19dfafd0b2e06d95e380)
2013-05-06 13:52:30 -04:00
Leo Franchi 0da2f51ddb Calculate presence information with delta between server timestamp
(imported from commit b4b367ed620878e6d01287cb1aaae0730c7475c8)
2013-05-06 13:52:23 -04:00
Steve Howell 6304a30257 Handle multiple casings of same subject in subject list. (#1227)
(imported from commit f1f675cd96a6d26c5b039d8f41c9373bc365cb45)
2013-05-03 14:28:23 -04:00
Leo Franchi 9362731e4d Mark messages behind pointer as read when moving pointer
(imported from commit 7e1d3d7124aec239a8fdd24da4aab682a41ff435)
2013-05-03 11:14:47 -04:00
Leo Franchi 33eef54c5b Re-send unread message counts if XHR fails
(imported from commit 062e76ca7db177540ed4e9ab0d331b9ecc2ee5f1)
2013-05-03 11:14:46 -04:00
Tim Abbott 6b85eaf16f Only mark messages in all_msg_list as unread.
(imported from commit 8c76ee8be918beeea44e70cba702fa45abff2297)
2013-05-02 15:35:46 -04:00
Zev Benjamin 3b6713d545 Improve message_range's running time
We also now check that start != -1, as that is probably a mistake.

(imported from commit 7065ed40150fda7b373d137129c0944a8fa03fc1)
2013-05-02 12:03:18 -04:00
Zev Benjamin 54bd4516ed Only update recent subjects after all messages in a batch have been processed
We were previously doing this on every message.  Because
update_recent_subjects is linear in the number of streams in the
sidebar, this became very slow when we enabled the streams sidebar
for the MIT realm.

(imported from commit 95cd71d83bbcc08cc6c5c79ca567b5d6b9b17173)
2013-05-02 12:03:18 -04:00
Zev Benjamin e1c8d2f50f Return match_subject and match_content from messages_in_narrow()
This fixes a bug where if you were narrowed to a search and received
a new message that belonged in that search, the message would appear
to have an empty subject and content.

(imported from commit fe1dbf584d3659d57c5b70c7eb45cb22bbc9732f)
2013-05-01 21:52:04 -04:00
Leo Franchi d0b8a2fd21 Mark messages as read when using the End key
(imported from commit b2495cb27b1362d037e786db7f108540f2ce655b)
2013-05-01 17:26:19 -04:00
Zev Benjamin c08a86aeb9 Use server-highlighted subject and content when narrowed to a search
(imported from commit 0579193da040db77f9c7937d3714cb9ffeaf7ed8)
2013-04-30 11:40:27 -04:00
Zev Benjamin 8b3e800bf5 Use the filter on MessageLists when adding messages
(imported from commit c9070e5413352aef612b4763c35a4c72f4ecb852)
2013-04-26 17:45:25 -04:00
Zev Benjamin 8474675076 Attach Filters to MessageLists
This should allow us to stop special-casing the narrowed message list
as much.

(imported from commit 1eb7216fbd8aa16b796c239a189d6ce0008344f9)
2013-04-26 17:45:25 -04:00
Zev Benjamin 4f4e982ed1 Don't do narrows with search operators on the client
(imported from commit 98e6a06f5c10a384e6295b3281d23a061ecdecab)
2013-04-26 17:45:25 -04:00
Zev Benjamin 6cdc3f67df Only fetch an extra message in get_old_messages if a narrow isn't specified
In the case where we're getting old messages for a narrowed view, the
anchor message id might not actually be in the result set so there's
no reason to fetch an extra message.

(imported from commit e610d1f2cb95be3ff9fce6dc95e40c560bc5bf84)
2013-04-26 17:39:08 -04:00
Tim Abbott 1c57956bf6 Avoid an unnecessary load_old_messages call on page load.
Previously, our check for whether we needed to call load_old_messages
a second time on page load to get up to the present caused us to
basically always do such a call.

(imported from commit b599041e8c0853b4c8c9ab2def6679142302523e)
2013-04-24 10:44:56 -04:00
Jessica McKellar de902be108 Add client support for restoring a message draft.
(imported from commit 64da07d4f9a7ba8e1548271f98e455ecd202da4a)
2013-04-22 11:14:03 -04:00
Tim Abbott de5038f4d7 Store the recipient stream name in message.stream.
Previously we were using message.display_recipient everywhere, which
is actually pretty confusing.

(imported from commit a58471172e28c039af8e290362e54b6660543924)
2013-04-22 11:14:03 -04:00
Tim Abbott bad18f6971 Display heading on boundary between historical and non-historical.
(imported from commit b1669725d5a10ae086d04d0aa03341bcb0b8b858)
2013-04-12 15:43:41 -04:00
Tim Abbott 6ca1cf8978 Rerender the message list when receiving out-of-order messages.
This should fix the problems we've been having with out-of-order
message deliveries, and is also an important prerequisite for showing
historical messages.

(imported from commit 77a18a526bf8ec4f1f70b776ac8b7e189d00bcf4)
2013-04-12 15:43:41 -04:00
Tim Abbott ca4baa01e0 load_old_messages: Clean up for_narrow parameter.
(imported from commit 1be9959ec3998371f24f9d11a9aa87e59d85aabf)
2013-04-12 15:43:41 -04:00
Tim Abbott 12416bb128 add_messages: Remove unused opts argument.
(imported from commit 5805348c39ec0db54b6bc6939ce2d85b4896500c)
2013-04-12 15:43:41 -04:00
Leo Franchi ecdb2acf79 Chop subjects to max of 5 regardless of timestamp of incoming messages
(imported from commit a58cd25d9c129729e0eb42ae090f4c715b5e20fe)
2013-04-12 12:47:41 -04:00
Leo Franchi f6984e4d23 Sort subjects properly
(imported from commit e2cb3d3c7e6dd3de09ffcfc6622e524fc4b7ff7d)
2013-04-12 12:28:04 -04:00
Leo Franchi 9130f6722f Show latest 5 subjects in sidebar when narrowed to a stream
This is a V1 of this feature. For now, the only way to expand is by narrowing
to the stream---future revisions may add a manual toggle if it is found to be
useful.

Additionally, showing per-subject unread counts will be coming in a future revision
as well.

(imported from commit fb5df0d27e928fa3b0f32b9ff2c1c508202cf7e5)
2013-04-12 11:51:09 -04:00
Leo Franchi 302cfcd48c Send client information for initial presence and process time differential
(imported from commit 99a51b7cc8b6c51c4e82757a984d07603b2980e3)
2013-04-12 09:11:40 -04:00
Leo Franchi 5d4b2305fe Send presence updates when a new user logs in for the first time, and when returning from inactive
This commit will incorrectly list past-online users as active, a shortcoming that is
addressed in the next commit

(imported from commit b018767df686f88c0ca939c067c573e4d7cea357)
2013-04-12 09:11:40 -04:00
Zev Benjamin a701083f71 Report additional information for "message in the middle of msg_list" errors
Hopefully this will help us track down what the problem is.

(imported from commit b8e30ee23ab8f1bf93525faa4f52ce9a4ccc9013)
2013-04-04 17:42:09 -04:00
Zev Benjamin de1f4b0be2 Remove all inline event handlers
This allows blueslip to catch exceptions from the event handlers on
these elements in addition to the other benefits that not using
inline handlers provide.

(imported from commit 2bdcb2496c6c08fa7228a20ce6164b527cf64e41)
2013-04-04 11:34:32 -04:00
Tim Abbott 3a93c8cc90 Fix pointer jumps on unnarrowing after certain scroll events.
This appears to have been caused by our code for preventing the
viewport from being recentered if you move the pointer away from the
edge of the viewport from a position near the edge, which was being
run even when it was not triggered by a scroll event.

(imported from commit 0a4b3dcca75a6e5dbf1beb77a5249bd6a9c61341)
2013-04-03 13:38:41 -04:00
Jessica McKellar 33a9bae5d1 Tailor empty narrow messages to what you were narrowing for.
(imported from commit 876afce2a63d4d6a522ac5300349b2be8805405f)
2013-04-01 14:26:50 -04:00
Zev Benjamin ee9f040040 Handle subscription events in the web client
This has the nice side effect of not requiring us to trigger the
events manually in the success callbacks of our subscribe/unsubscribe
ajax calls.

(imported from commit e8d9970b708e9832d22be4803570071bacb46792)
2013-04-01 13:07:48 -04:00
Zev Benjamin bd81706558 Handle realm_user events in web client
We currently only use these events to change the autocomplete lists.
I figure that the presence list will be updated by presence events.

(imported from commit e9c1466659c4bfd463806656e0023984a4ea4177)
2013-04-01 13:07:48 -04:00
Jessica McKellar 3df47f2025 Do not try to recenter if you were already moving in the right direction.
Before this commit, if you try to arrow around when the selected
message is outside the pointer threshold for recentering, you get a
big jump, even if you are arrowing towards the center of the viewport.

(imported from commit 5c15d5ccccdf027a8bfa8b79bf519fccbfa971d8)
2013-03-28 17:08:25 -04:00