Commit Graph

48 Commits

Author SHA1 Message Date
Steve Howell 6183a0d8b2 bug fix: Handle invalid streams in would_receive_message(). 2017-03-05 11:55:09 -08:00
Steve Howell 976185da30 Streamline compose fading for presence updates.
We now only update the new element.
2017-02-28 16:40:10 -08:00
Steve Howell b83d10345a Extract update_user_row_when_fading(). 2017-02-28 16:40:10 -08:00
Steve Howell 9791e2f570 Populate focused_recipient.to_user_ids in compose_fade.js. 2017-02-26 16:18:02 -08:00
Steve Howell 4d0d18ba14 Use stream_id in recipient comparisons.
Using stream_id in recipient comparisons fixes a
bug in this scenario: go to home view, send message
to stream, wait for admin to rename stream, send
another message to the stream.  Before this change,
the stream name would live-update but you'd get a
spurious recipient bar due to the prior message still
having the old stream name in places internally.

There were other ways to fix the live-update glitch,
but it's just generally cleaner to do stream id
comparisons.

Part of this change is to add stream_id to
compose_fade.set_focused_recipient().
2017-02-26 16:18:02 -08:00
Steve Howell c02cf5dd5c Extract compose_fade.should_fade_message(). 2017-02-26 16:18:02 -08:00
Steve Howell 96ca684d40 Remove feature_flags.fade_users_when_composing. 2017-02-26 16:18:02 -08:00
Steve Howell 807afc87ba Remove feature_flags.fade_at_stream_granularity. 2017-02-26 16:18:02 -08:00
Steve Howell 73125e2718 refactor: Move is_current_user() to people.js.
We no longer have it in util.js, because we will
want to encapsulate this better for upcoming commits
related to email changes.
2017-01-21 21:45:12 -08:00
Tim Abbott 998dff9e50 lint: Add dangling commas in JavaScript objects. 2017-01-11 15:23:42 -08:00
Rafid Aslam 45f39be37f lint: Fix many no-unused-vars eslint rule violations.
These have been carefully audited by tabbott to ensure they are
unlikely to cause regressions.
2016-12-14 21:34:51 -08:00
Rafid Aslam 7856217a63 Migrate JS modules to CommonJS style.
Closes #1488.
2016-12-07 16:11:52 -08:00
AZtheAsian ed0bc831be eslint: change one-var from warning to error and fix violations 2016-12-02 11:25:16 -07:00
Tommy Ip b3f4feb996 eslint: change max-len from warning to error and fix violations. 2016-12-02 14:16:33 +00:00
kevv87 e6369fc29b eslint: change no-plusplus from warning to 2 and fix violations. 2016-12-01 14:27:17 -08:00
Steve Howell aadfe133e2 buddy list: Use user_ids in DOM list elements. 2016-11-26 11:48:52 -08:00
Tim Abbott c35781d505 lint: Require folding of } on same line as else statements. 2016-06-09 14:02:49 -07:00
Tim Abbott a829366733 util: Create and use is_pm_recipient helper function. 2016-06-07 21:58:45 -07:00
Tim Abbott b25562ca1d Add and use util.is_current_user helper function.
Previously, we were checking if a particular user was the current user
in dozens of places in the codebase, and correct case-insensitive
checks were not used consistently, leading to bugs like #502.
2016-06-07 21:58:44 -07:00
Givorenon 0bf2d171ae Fix fading of messages in dialog and users in side-bar.
Make comparison of emails in compose_fade.js and util.js
case-insensitive to fix fading of users and messages respectively.
2016-06-07 21:31:47 -07:00
Jason Michalski 7bc98d1634 Update the message group fading to be message_container aware
update_rendered_message_groups needs to use the message not the
message_container when testing to see if the fade states need to be
updated.

(imported from commit b1c3baba07169a369d827c89afdc3c406ada0b79)
2014-03-18 16:13:04 -04:00
Jason Michalski e60f76487f Rename message to message_container
Now that we are not directly using message in the message list view
rename the uses of message that are message_containers.

(imported from commit 5c355703a8934a74864f5de6ecb1e2fd851e5d41)
2014-03-18 15:05:39 -04:00
Steve Howell 405c3d7626 Created floating_recipient_bar.js (with code from ui.js).
(imported from commit 2b6631938b0fc8e39c14aacd92f9f1670b68b199)
2014-03-14 20:48:58 -04:00
Leo Franchi 63bcf98e71 Fade properly via groups when toggling fade on compose
(imported from commit 865c9daf8a267cfa65f7daceddff55a816b9c22c)
2014-02-27 20:25:34 -05:00
Leo Franchi dbb3bf6a4d Fade by groups when rerendering
(imported from commit 31f472bb87eaa03bf38dddcc696e843d93e68e08)
2014-02-27 20:25:28 -05:00
Leo Franchi 568c33f294 Render messages as groups of divs instead of individual rows
Now that we no longer use tables for our message list, we can
more logically group messages together.

(imported from commit 9923a092f91a45fe3ef06f2f00e23e4e3fb62a37)
2014-02-27 20:25:23 -05:00
Jessica McKellar 3a6df13360 Don't fade messages on different topics but the same stream.
(imported from commit 1bc2d49b346619609e73794d237faf2352b974b3)
2014-02-12 16:26:57 -05:00
Tim Abbott 88fbd5d16a Split out new module message_store.js.
(imported from commit 57cf3f2b8e74d7c56e3baf75859d5b3646282225)
2014-01-31 15:57:28 -05:00
Tim Abbott e505583f52 Split out new module people.js for tracking people.
(imported from commit fb9b769819ade25d1d3d6e452e68c7ee8651cfdd)
2014-01-30 17:32:58 -05:00
acrefoot 9e50781131 Random javascript shortenings
(imported from commit 68a34d67ac38e34035a3e3986518824bf5a96fc5)
2013-11-13 16:41:36 -05:00
Tim Abbott 66cb29e60e Don't do second-stage fading if the compose box was closed in between.
(imported from commit 4c8ad3befe845db9a640e73925bd0928d6943178)
2013-11-06 15:35:48 -05:00
Jeff Arnold 6483314f74 Only fade visible messages before rendering compose box
Partially addresses #1963

(imported from commit 0c941085ab6894e8e43015a116c49a5bdc674b5f)
2013-11-04 16:27:39 -05:00
Kevin Mehall 89d149c6f7 Fix @-mention "not subscribed" warning for all_public_streams bots.
Don't warn when @-mentioning a bot on a public stream that it does
not appear to be subscribed to. It may be receiving those messages
anyway.

(imported from commit 4a00694942a721897a01736f48033c71048e0b16)
2013-10-18 14:55:32 -04:00
Steve Howell be9eea6cd4 Disable compose fading for incomplete/wrong stream names
(imported from commit 2b6a0dbcd1464767e24704f270eeac2875be0d51)
2013-09-25 14:43:43 -04:00
Leo Franchi 0cf588cd25 Show a warning and action button when @-mentioning someone not on the stream
(imported from commit 464d5a028f6a8f2698683e7317972dc0c7b9e336)
2013-09-17 16:49:47 -04:00
Scott Feeney 5d800c5186 Fade users when composing
This is feature-flagged to staging only.

There are basically 3 parts to the implementation:

1. In response to typing, fade/unfade the user list.
2. When a compose is aborted, unfade all users.
3. When the presence list is redrawn, fade/unfade the user list again.

(imported from commit cd416de232849a9f69dcacdc8b0fcfc20e3848a2)
2013-09-06 23:13:48 -04:00
Kevin Mehall 3345199604 Hide/show the floating recipient bar when fade state changes.
This partially reverts d3c28b17859cacd49b7db9f8784d4b8b9069e1ff.

It is necessary to call update_floating_recipient_bar from _fade_messages and
_want_normal_display because they are called after opening/closing the compose
box. There is no scrolling there, so it is not otherwise updated. It is not
necessary to call from update_rendered_messages as it is not called on
changes of the fade state.

Related: Trac #1682

(imported from commit e2528f8c8827b7e2a135d7fc2b53e9e8162799b0)
2013-08-15 18:26:36 -04:00
Steve Howell 59b84aad4a Properly fade recipient bar of incoming messages.
This fixes #1682, a recent regression that came out of
a5a47e13fc9d, which introduced the update_rendered_messages()
function in compose_fade.js.  The original implementation
was finding the table row for a message, but not the table
row for its recipient bar.  Now we style both elements.

(imported from commit a9628df0b03f79a24dfa68f4f2061eda2ca8ecea)
2013-08-14 13:20:39 -04:00
Steve Howell d66ac9f36c Remove calls to update_floating_recipient_bar in compose_fade.js.
The calls to ui.update_floating_recipient_bar() were brought over
from compose.js, and it turns out they just complicate scrolling,
since we already call the function in the scroll handler.

(imported from commit d3c28b17859cacd49b7db9f8784d4b8b9069e1ff)
2013-08-14 13:20:38 -04:00
Steve Howell 1c9749d21e Debounce update_faded_message on the trailing edge.
This resolves trac #1675, without introducing the problem that
caused us to set the immediate flag in the first place.  (Some
commits just prior to this eliminate some slowness with rendering
by taking the debounced function out of the code path.)

(imported from commit 8c72f25a9d5eb38376957f222b9413d3167fa386)
2013-08-13 17:14:07 -04:00
Steve Howell beb89e247f Avoid unnecessary fading/unfading processing via message_list.
The call to compose_fade.update_faded_messages() in message_list
caused us to traverse every message in the current table, which
was extremely inefficient.  Now we call the newly created
compose_fade.update_rendered_messages(), which only fades/unfades the
messages passed in as the first parameter.

(imported from commit a5a47e13fc9daeedd0899b2cfb02beb3f6b8cd0a)
2013-08-13 17:14:06 -04:00
Zev Benjamin 62f607fd5e Debounce fading on the leading instead of the trailing edge
(imported from commit 11d0e8938c1f29cfea0678330e7af9884844af21)
2013-08-12 18:07:30 -04:00
Steve Howell c4e168254c Fix too-much-fading regression and remove spurious classes.
To get to the bottom of the too-much-fading regression,
it was necessary to clean up the code, which was overly
complicated by multi-purposed functions.

The API for compose_fade now has these functions:

    set_focused_recipient
    start_compose
    clear_compose
    update_message_list
    update_faded_messages

Internally there is now a notion of "normal display",
so e.g. when you want a normal display, we call
_diplay_messages_normally() internally, which removes the
faded/unfaded classes from all messages.

(imported from commit 7eb2b0a163f29d9ebae26661f432fecc7c331e4c)
2013-08-12 11:54:27 -04:00
Steve Howell e720737cb5 Tune fade/unfade bouncing from 150ms to 50ms.
This makes fade/unfade start sooner (good), but it might
re-introduce some typing sluggishness (bad).

(imported from commit 4e3112ed1ac931f2931182f91b60567ef2d72695)
2013-08-11 18:18:01 -04:00
Steve Howell 6591c79184 Un-debounce fade/unfade when starting a compose.
When starting a compose, call compose_fade.set_faded_messages,
which will immediately do fade/unfade logic, whereas before
the code path went thru debouncing logic.

(imported from commit 7d0b30435be32a7132dbf05bf064b03b925a2d42)
2013-08-11 18:08:36 -04:00
Steve Howell 6cc5c43e59 Move code into compose_fade.set_focused_recipient().
Move code from compose.update_fade() into
compose_fade.set_focused_recipient(), which makes it
so that we only have to send the msg_type.

(imported from commit c17665d9f34f525bdedcd36d39d3a112fa36a914)
2013-08-11 17:54:50 -04:00
Steve Howell 8190cdc9fb Avoid redundant O(N) work in unfade_messages()..
The code in unfade_messages() is O(N) over the number of
messages, but a simple flag allows us to track the fact that
all messages are unfaded, so we can short circuit the O(N)
logic in many cases.

A typical scenario now would be that you start typing a
stream while the topic is still empty.  Modulo debouncing,
every keystroke now leads to a call to unfade_messages(),
but this change only does real work the first time.

(imported from commit da07cf408bbdbf5b381ff3ec33a5e05e34eef5b5)
2013-08-11 17:05:13 -04:00
Steve Howell 37f8cc9294 Extracted code into compose_fade.js.
The compose_fade has three public exports:

    set_focused_recipient
    unfade_messages
    update_faded_messages

All code was pulled directly from compose.js, except for the
one-line setter of set_focused_recipient.  The focused_recipients
variable that used to be in compose.js was moved to compose_fade.js,
hence the need for the setter.

(imported from commit 462ca5d0d0bd58612d0197f3734a8c78de8c6d30)
2013-08-11 17:05:13 -04:00