Commit Graph

170 Commits

Author SHA1 Message Date
Cynthia Lin a65007dde4 right sidebar: Ensure .user-with-count gets added to correct li element.
The count_span element is parented by a .selectable_sidebar_block element
which is parented by the li element that the class is supposed to be added
to. Thus, use the parents() jQuery method for locating the li parent so
that the class gets added to the correct element.
2019-07-16 11:33:02 -07:00
vsvipul e830853aee desktop-presence: Use system presence data from electron-bridge.
Combined with work in the desktop app, this makes it possible for the
desktop app to clearly indicate to other users whether the current
user is active on the system and thus would see a desktop
notification, not just whether they are active in the current Zulip
window.

Essentially rewritten by tabbott to add unit tests and consider the
desktop app data authoritative.
2019-07-13 11:21:22 -07:00
Anders Kaseorg db0b33842c templates: Replace templates.render with require calls.
This removes an unnecessary layer of indirection and allows webpack to
catch filename mistakes.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-07-12 21:11:14 -07:00
Tim Abbott 5c32e2ff49 popovers: Fix migration to popovers.hide_all_except_sidebars().
I'm not really sure how I missed this in the original commit.
2019-07-09 23:03:41 -07:00
Tim Abbott e59a49ade5 activity: Refactor logic for sending active status.
This is a preparatory refactor for extending this logic to interact
with the desktop app as well.
2019-06-28 18:06:31 -07:00
Tim Abbott 793524618b activity: Rename confusing focus_ping function.
This function sends presence to the server and gets the server's
presence data back; it has nothing to do with browser focus.
2019-06-28 18:06:31 -07:00
Tim Abbott 746206f071 activity: Rename has_focus to client_is_active.
This makes it a lot more clear what it actually means, which is not
directly related to whether the browser window is focused.
2019-06-28 18:06:30 -07:00
Tim Abbott 42d29d58a1 activity: Rename focus_lost/focus_gained functions.
These names were incorrect, as they made it sound like this feature
was about the browser window being focused, whereas they are in fact
about whether the user has accessed the browser window.
2019-06-28 17:50:32 -07:00
Anders Kaseorg 01613e71fb ui: Replace set_up_scrollbar with data-simplebar attribute.
With perfectScrollbar, we needed to call a function from JavaScript to
enable a scrollbar on a new element, but simplebar has a much simpler
default API one can do by using data-simplebar attributes in the HTML.

So we can delete all the scrollbar creation/deletion code.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-05-19 18:06:38 -07:00
Anders Kaseorg 141088586b Completely replace perfect-scrollbar with SimpleBar.
perfect-scrollbar replaces both the appearance and the behavior of the
scrollbar, and its emulated behavior will never feel native on most
platforms.  SimpleBar customizes the appearance while preserving the
native behavior.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-05-17 12:06:51 -07:00
Thomas Ip a2872c107e typescript: Move TS files into JS directory.
This is just a code reorganization to avoid making it difficult to
find things as we migrate more file to TypeScript.
2019-03-25 12:11:37 -07:00
Thomas Ip 7d050ab0cf typescript: Migrate dict.js to typescript. 2019-03-21 10:48:44 -07:00
Steve Howell e67cf30dfd private messages: Add user circles to top left.
This is mostly adding markup, calling some convenient
functions in buddy_data.js, and adjusting CSS.

To make the circles update dynamically, I mostly
orchestrate this though activity.js for now.  It's
possible we'll want to adjust that eventually to
happen through something like a `presence_events`
dispatcher, but that's essentially what
a good part of `activity.js` does now.
2019-02-18 14:22:37 -08:00
Steve Howell a6fdac128f refactor: Move huddle_fraction_present() to buddy_data.
This is a pure data function, so there's no sense having
future callers go through activity.js.
2019-02-18 14:22:37 -08:00
Abhinav Singh 849c296f90 popovers: Fix 'w' hotkey in narrow windows.
In small screen sizes, when the user presses shortcut `w` to search
for another user, the hide_all function calls in the search code path
would hide the right sidebar, immediately after opening it, making the
hotkey basically unusable.

We fix this by extracting a separate hide method that hides all true
popovers, but not the user list sidebar.

Fixes #11463.
2019-02-08 08:42:34 -08:00
Abhinav Singh 07bac66db7 right sidebar: Hide user detail popover correctly.
This code will hide the user detail popover correctly
when the user wants to search other users.

Fixes #11362.
2019-01-31 11:58:24 -08:00
Steve Howell 49b16b5b01 activity: Rename function to redraw_user().
The name `insert_user_into_list` is sort of misleading,
since we are often just redrawing the user's existing
item in the buddy list.

I chose `redraw_user` over `update_user` to emphasize
that we're just going to redraw it with whatever data
has been updated by the callers.
2019-01-25 16:53:51 -08:00
Steve Howell 4fed3d2014 frontend: Add event handling for user status.
The UI part of this commit isn't really turned on
yet, but it works in theory.
2019-01-02 09:16:31 -08:00
Steve Howell f4f59a7557 presence: Rename presence.set_user_status() -> set_info_for_user(). 2018-12-18 11:01:10 -08:00
Steve Howell ba69dcc74c presence: Rename activity.set_user_status().
We are trying to carve room for a more specific
"user_status" concept, which refers to statuses
that users specifically set, like "I'm away".

So we call this function "update_presence_info",
which reflects that it's more about actual
"presence"--i.e. the user really is present
in the browser, even though the actual human
may not want to be disturbed.
2018-12-18 11:01:06 -08:00
Steve Howell 3aa490edbe Add current user back to the buddy list.
For many years we have been excluding the current user
from the buddy list, since their presence is kind
of implicit, and it saves a line of real estate.

This commit removes various user-is-me checks
and puts the user back for the following reasons:

    * explicit is better
    * newbies will be less confused when they
      can see they're actually online
    * even long-time users like myself will
      feel more comfortable if it's just there
    * having yourself in the buddy list facilitates
      things like checking your presence or sending
      yourself a message
    * showing "me" reinforces the meaning of the
      green circle (if my circle is green and I'm
      active, then others with green circles must
      be active too)
    * If you're literally the first user in the
      realm, you can now see what the buddy list
      looks like and try out the chevron menu.

The biggest tradeoff here is the opportunity cost.
For an org with more people than fit on the screen,
we put the Nth person below the fold to show "me".
I think that's fine--users can still scroll or
search.

This commit doesn't do anything special with the
current user in terms of sorting them higher in the
list or giving specific styling.

Fixes #10476
2018-11-27 14:52:19 -08:00
Steve Howell a866f3ec17 refactor: Move huddle_with_uri to hash_util. 2018-08-04 09:32:27 -07:00
Steve Howell c7ab3884c6 refactor: Extract reload_state module.
This is part of work to break some of our
nastier circular dependencies in preparation
for our es6 migration.

This commit should facilitate loading leaf-like
modules such as people.js before all of the things
that reload.js depends on.
2018-08-04 13:55:02 +00:00
Steve Howell 94884a4418 buddy list: Introduce buddy_list_wrapper div.
This new div allows us to split out two concerns:

    semantic list of items - remains in #user_presences
    widget real estate - controlled by new #buddy_list_wrapper

We will use this for progressive rendering.  We want to add
padding to the buddy list without messing with the integrity
of the actual HTML '<ul>' list.  (One ugly alternative would
have been to add a dummy list item, which be a pitfall for
any code traversing the list.)

Basically, all the code relating to click handlers and similar
things was left alone.  We only change js/css related to
scrolling, resizing, and overflow.
2018-08-02 16:56:50 -07:00
Steve Howell 1a84af1e79 buddy list: Add v1 progresive scrolling.
This version of progressive scrolling lazily
renders buddy list items, but it doesn't
provide the browser with any notion of upcoming
list items, so as you scroll down and the size
of the rendered list grows, the scrollbar shows
you being too close to the bottom.

This maintains 100% coverage on buddy_list.js.
2018-08-02 16:56:50 -07:00
Steve Howell 5cdce82f7c refactor: Add compare_function to buddy_list.
We were passing this in before, but having it as
a data member reinforces the idea that we'll want
this to be a first-class concept in the list, since
we depend on ordering for various things.
2018-07-25 15:53:27 -07:00
Steve Howell d69b3a3c71 refactor: Track user_ids in buddy_list.js.
We now keep track of keys in buddy_list.js, so that
when we insert/remove items, we no longer need to
traverse all the DOM.  Instead, we just find out
which position in the list we need to insert the
key in (where "key" is "user_id") and then find
the relevant DOM node directly and insert the new
HTML before that node.  (And of course we still
account for the "append" case.)

There's a little more bookkeeping to make this
happen, but it should help reduce some code in
upcoming commits and pave the way toward
progressive rendering optimizations.

This commit should produce a minor speedup
for activity-related events that go through
buddy_list.insert_or_move(), since we are
not traversing the DOM to find insertion points
any more.
2018-07-25 15:53:27 -07:00
Armaan Ahluwalia 6d255efe4c app: Prepare JS files for consumption by webpack.
This commit prepares the frontend code to be consumed by webpack.

It is a hack: In theory, modules should be declaring and importing the
modules they depend on and the globals they expose directly.

However, that requires significant per-module work, which we don't
really want to block moving our toolchain to webpack on.

So we expose the modules by setting window.varName = varName; as
needed in the js files.
2018-07-05 10:53:36 +02:00
Shubham Dhama 80a2d5bc59 eslint: Enable `conditionalAssign` config of no-trailing-spaces rule. 2018-06-11 07:51:24 -04:00
Shubham Dhama dcb6254a4e eslint: Enable `no-extra-parens` rule.
Following sub-configuration is disabled:
                "nestedBinaryExpressions": false,
2018-06-11 07:51:24 -04:00
Tim Abbott 7ab8a8e820 js: Fix a bunch of indentation issues found by eslint.
This is preparation for enabling an eslint indentation configuration.
90% of these changes are just fixes for indentation errors that have
snuck into the codebase over the years; the others are more
significant reformatting to make eslint happy (that are not otherwise
actually improvements).

The one area that we do not attempt to work on here is the
"switch/case" indentation.
2018-05-06 16:25:02 -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 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 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
Tim Abbott e4c50ff4fd narrow: Remove unnecessary select_first_unread option.
We consistently either pass a `then_select_id` into narrow.activate,
or were using the select_first_unread option.  Now, we just compute
select_first_unread based on the value of then_select_id.
2018-04-22 21:33:33 -07:00
Steve Howell 76d83af62b buddy list: Extract activity.narrow_for_user.
This change makes a common code path for these two operations:
        * clicking on a user
        * hitting enter when a user is highlighted

The newer codepath, for the enter key, had some differences that
were just confusing.  For example, there's no need to open the
compose box, since that's already handled by the narrowing code.

For possibly dubious reasons, I let each handler still call
popovers.hide_all() on its own, since it makes the code a bit
more consistent with existing code patterns.
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
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
aedorado c98d355321 right-sidebar: Fix clicking between Users label and search icon.
This brings the right sidebar UI to match the similar widget in the
left sidebar.  Since there's no other plausible effect for a click in
this whitespace, this small tweak should make using Zulip a bit more
convenient.

Fixes #8161.
2018-01-27 16:29:44 -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
derAnfaenger 19bc55aa45 Fix various typos.
The typos and their corrections were found with the
aid of https://github.com/lucasdemarchi/codespell.
2017-11-09 16:26:38 +01:00
Steve Howell 646bd356a3 Rename get_realm_human_user_ids -> get_active_user_ids.
The function name `get_realm_human_user_ids` was a lie--it
includes active bots as well.

The only user of this function is `activity.js`, which wasn't
impacted by the misleading name, because we eventually filter
out bots in the `info_for` function.

It's possible that we actually want to include bots in the right
sidebar, since they can be difficult to discover in other parts
of the UI.  Or, if we want to keep the right sidebar as all
human users, we may eventually want to make the logic to exclude
bots happen higher in the stack (but for real, this time).
2017-10-26 09:17:43 -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 6888255153 Add people.get_realm_user_ids().
This saves us from doing an unnecessary map() in
activity.js.
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