Commit Graph

67 Commits

Author SHA1 Message Date
Rohitt Vashishtha cba2c529f9 zblueslip: Convert node_tests/activity.js to zblueslip. 2018-05-03 16:27:05 -07:00
LuisFSilva a072b2a153 right-sidebar: Fix group PMs online indicator.
People found it confusing that it would show up at light-green when
the users in the thread were idle.

Fixes #8242.
2018-05-02 12:41:01 -07:00
Steve Howell 97b9367d20 refactor: Extract scroll_util.js.
We now use scroll_element_into_container() in two different
places, so it's worth extracting.
2018-04-28 11:15:14 -07:00
Steve Howell 068e4bf32b buddy list: Populate user-fade via templates.
When we populate the buddy list or update it for activity, we now
have buddy_data set a faded flag that is rendered in the template.
This avoids some re-rendering overhead and is on the eventual path
to having our widget be more data-oriented (and all rendering happens
"behind" the widget).

We still do direct DOM updates when the compose state changes or
when we get peer subscription events.
2018-04-28 11:15:14 -07:00
Steve Howell fb712027bf buddy list: Fix and simplify up/down navigation.
This introduces a generic class called list_cursor to handle the
main details of navigating the buddy list and wires it into
activity.js.  It replaces some fairly complicated code that
was coupled to stream_list and used lots of jQuery.

The new code interacts with the buddy_list API instead of jQuery
directly.  It also persists the key across redraws, so we don't
lose our place when a focus ping happens or we type more characters.

Note that we no longer cycle to the top when we hit the bottom, or
vice versa.  Cycling can be kind of an anti-feature when you want to
just lay on the arrow keys until they hit the end.

The changes to stream_list.js here do not affect the left sidebar;
they only remove code that was used for the right sidebar.
2018-04-28 11:15:14 -07:00
Steve Howell f11b3c9934 buddy_list: Clean up selector references.
In this cleanup I make it so that all jQuery selector references
are toward the top of the module, and we do all finds relative
to the container ('#user_presences').

This will make it easier to make a better list abstraction for
the buddy list, for things like progressive rendering.
2018-04-28 11:15:14 -07:00
Steve Howell 65d8eb3189 buddy list: Extract user_search.js.
This was a bit more than moving code.  I extracted the
following things:

        $widget (and three helper methods)
        $input
        text()
        empty()
        expand_column
        close_widget
        activity.clear_highlight

There was a minor bug before this commit, where we were inconsistent
about trimming spaces.  The introduction of text() and empty() should
prevent bugs where users type the space bar into search.
2018-04-28 11:15:14 -07:00
Steve Howell 4b3d07c805 node tests: Localize focus logic for activity.js.
This does a few things:
        * removes some unnecessary setup
        * puts some jQuery setup closer to where it's needed
        * renames some variables
        * adds an assertion about highlighting
2018-04-22 20:08:08 -07:00
Steve Howell 3f1930f9c5 buddy list: Extract buddy_data.js. 2018-04-22 20:08:08 -07:00
Steve Howell 536236d9b1 buddy list: Extract buddy_list.js. 2018-04-22 20:08:08 -07:00
Priyank 02dddd6b35 node_test: Use let/const instead of var in activity.js.
This was left in previous cleanup.
2018-04-20 15:46:28 -04:00
Priyank 6faa6f96e9 node_test: Convert function to arrow function where needed. 2018-04-17 12:56:25 -04:00
Priyank 7490932e1b node_tests: Use const for constants. 2018-04-17 12:56:25 -04:00
Florian Jüngermann ec3e0caece right-sidebar: Enable up and down arrow keys.
This users the new generic functions in stream_list.js to implement a
similar behaviour for the right sidebar (user list).

Fixes #5920.
2018-02-12 15:38:23 -08:00
Cynthia Lin da06832837 right-sidebar: Make Search people input collapsible with search icon.
Fixes #4816
2018-01-07 15:05:03 -05:00
Cynthia Lin 940ca17c46 hotkeys: Expand collapsed sidebars when sidebar searches are initiated.
Fixes #7351.
2017-11-14 11:12:13 -08:00
Steve Howell 7a68add9a4 Remove unneeded requires in activity.js. 2017-11-08 12:24:17 -08:00
Steve Howell ae139a78b8 presence: Change "unknown" to "offline".
We never make an actionable distinction between the "unknown"
presence status and the "offline" status, so we now
just use "offline" as the status for persons who don't
have recent presence records that the client knows about.

(Usually, users without presence rows have never been online,
or they have been deactivated, or they have been offline so long
that they don't show up in our date-limited queries.)
2017-10-12 10:42:06 -07:00
Tim Abbott 8828e96b87 presence: Avoid checking activity when reloading.
We sometimes get blueslip errors from browsers that are clearly still
attempting to reload long after they should have.  These browsers can
produce a lot of unnecessary presence update exceptions.

To solve that, we start checking reload_in_progress in the presence
code path.

While we're at it, we also add some blueslip logging for the reload
code path, in case it becomes useful when debugging future issues.
2017-10-11 20:39:28 -07:00
Steve Howell 810532641e activity.js: Extract get_filtered_and_sorted_user_ids().
This function was extracted from build_user_sidebar().  We
also slightly streamlined it to not unnecessarily call
filter() when the filter text was blank. This extraction
also eliminated the need for us to have the two-line
filter_and_sort() function.

Also, we get to 100% coverage in this commit.
2017-10-08 12:01:59 -07:00
Steve Howell 943eefb7c0 activity.js: Extract get_filter_text().
We were using slightly different logic to get the filter
text in various places.  Now we're consistent, and it's
easier to test the edge-case behavior.
2017-10-08 12:01:59 -07:00
Steve Howell 3ef2df363b activity.js: Consolidate initialization code.
We now intialize user-list-filter within activity.initialize(),
which gives us more control to set the module variable
`meta.$user_list_filter` before we build the user sidebar,
while setting up its handlers after we build the sidebar.
2017-10-08 12:01:59 -07:00
Tim Abbott 0b765811b6 activity: Fix presence tests once again. 2017-10-04 21:58:16 -07:00
Tim Abbott 68e75833b7 activity: Fix the node tests.
These were unfortunately broken with the recent changes to filter all
users.
2017-10-04 21:06:51 -07:00
Brock Whittaker 983be4e8ce right-sidebar: Add perfectScrollbar to the right sidebar.
This adds the perfectScrollbar to the right side and theoretically
updates it any time a piece of code interacts with the sidebar and
updates the counts of users displayed in it.
2017-09-27 19:21:20 -07:00
Vaida Plankyte c9de03b163 frontend: Make perfectScrollbars pass tests. 2017-08-16 08:07:28 -07:00
Steve Howell d6b618e2eb Use zrequire in node_tests/activity.js. 2017-08-09 12:32:09 -07:00
Cory Lynch d32e89aae4 jQuery: Remove broken use of "removeAttr".
This function no longer sets properties to false, so the supported
way of doing this is to instead use prop(foo, false). Some tests
had to be fixed to accommodate this.
2017-07-24 10:54:47 -07:00
Steve Howell 7376934a77 zjquery: Add $.create() method.
This commit add $.create(), which allows you to create a
jQuery object that just has a name to identify it, as opposed
to some selector or HTML fragment.  It's useful for things that
are really used as stubs.

This also fixes a bunch of the existing tests to use $.create().

Before this fix, you could actually just do $('some-stub'), but
now we enforce that the input to $() looks like a valid selector
or HTML fragment, and we make some exceptions for things like
window-stub and document-stub.
2017-07-08 10:32:32 -04:00
Steve Howell ccd821e29b zjquery: Rename add_child() to set_find_results().
Hopefully this will make it more explicit that zjquery does
not truly simulate DOM, but it instead allows you to dynamically
set what you want the results of $('foo').find(some_selector)
to be.
2017-07-08 08:31:18 -04:00
Steve Howell 70407e080d zjquery: Require explicit set_parent() calls.
Before this commit, we were erroneously setting up parents
as part of add_child() calls, but it's not necessarily the
case that those children are immediate children, and therefore
the first object is not necessarily the immediate parent.
2017-07-08 08:21:27 -04:00
Steve Howell 99a6a9b70d node tests: Replace trigger() calls in activity.js.
We now use get_on_handler() to call event handlers, rather
than simulating a triggered event.
2017-07-06 08:46:36 -04:00
Aditya Bansal 232966a948 activity.js: Remove unnecessary override of i18n as global var. 2017-06-28 07:34:04 -04:00
Aditya Bansal d1fe75ce3b node tests: Enforce 100% node coverage in activity.js. 2017-06-26 14:24:20 -04:00
Vishnu Ks 9b16835c99 user_popover: Handle the case when user presence is unknown.
For bots and users who have not logged in for a long time the presence information is not known. For the these users make the presence indicator hidden.
2017-06-19 17:25:06 -04:00
hackerkid a158676fb0 Add function to get last seen status from last active date. 2017-06-11 07:09:21 -05:00
Steve Howell 6518c63b14 node tests: Add tests to activity.js. 2017-05-24 17:41:41 -07:00
Steve Howell 689605dd2e Introduce make_zjquery(). 2017-05-24 17:41:41 -07:00
Steve Howell 6c7a5260fc node tests: Add tests for filtering user ids in user list. 2017-05-24 17:41:41 -07:00
Steve Howell 5c09bec5e9 node tests: Use zjquery for entire activity test. 2017-05-24 17:41:41 -07:00
Steve Howell 4cfd9aa689 Add test coverage for activity unread counts. 2017-05-24 13:08:54 -07:00
Steve Howell a9f6f5f0c0 node tests: Split out presence.js. 2017-05-24 09:18:24 -07:00
hackerkid cf15a7b561 presence.js: Make get_status return active for logged in user. 2017-05-12 14:28:23 -07:00
fionabunny 78bcbc79d6 home.py: move people_list as realm_users to register_ret.
Simplify the page_params generation logic #3853
2017-04-28 21:33:33 -07:00
Steve Howell 2420df8415 buddy list: Make small realms show all users.
For small-ish realms (<= 250 users), we ensure that the presence
info includes all realm users the front end knows about, even in
cases where the server sends down a slimmed version of presence
data.  We make the users "offline" by default, of course.

This commit sets us up to optimize larger realms without concerns
of breaking small realms.  Small realms may want to continue to
show all users, even users who may have been offline several weeks,
since it doesn't clutter their API as much as it would for big
realms.
2017-04-04 15:57:10 -07:00
Steve Howell 2718bd0b5d Extract presence.js to track presence info.
Most of this code was simply moved from activity.js with some
minor renaming of functions like set_presence_info -> set_info.

Some functions were slightly nontrivial extractions:

    is_not_offline:
        came from activity.huddle_fraction_present

    get_status/get_mobile:
        simple getters

    set_user_status:
        partial extraction from activity.set_user_status

    last_active_date:
        pulled out of admin.js code

We also fixed activity.filter_and_sort to take user_ids.
2017-04-04 15:57:10 -07:00
Steve Howell fa729f11bd node tests: Speed up activity.js by stubbing jquery. 2017-04-04 06:31:37 -07:00
Harshit Bansal d17b759fa2 admin: Display last active time of users in admin users table.
Fixes: #2097.
2017-03-27 13:39:47 -07:00
Rishi Gupta 19d8d16126 js dependencies: Split hash_util.js from hashchange.js. 2017-03-18 20:40:34 -07:00
Steve Howell 27f37e6378 Add hash_util.encodeHashComponent() shim. 2017-03-18 15:52:50 -07:00