Commit Graph

173 Commits

Author SHA1 Message Date
gooca 591624972e Refactor perfect-scrollbar: Call ui methods in stream_list.js. 2018-03-16 12:47:47 -07:00
Florian Jüngermann b489ccc126 left-sidebar: Enable up and down arrow keys.
When in the stream-searchbar, a user can now use the arrow keys to iterate
through the suggestions. Therefore the currently selected list element is
assigned a CSS class 'highlighted_user'.
The main functional testing is done with casper but node test are still
included to keep the high coverage.
Line-wrapping issues are resolved. Night-mode CSS handling is included.
2018-02-12 15:35:56 -08:00
Logan Williams 53e4dc1a46 left sidebar: Clicking on a stream clears the stream search.
Clears and hides the search bar when a stream is selected from the
filtered stream list.

Fixes: #7909.
2018-01-29 11:04:48 -08:00
YJDave c22285c154 stream settings: Allow org admin to update settings of unsub-stream.
As per backend validations.
2018-01-22 18:26:36 -05:00
Cynthia Lin 7c1a803927 left-sidebar: Fix styling of Streams header to not use links. 2018-01-07 15:05:03 -05:00
Greg Price ac7d086085 sidebar: Revert to narrowing to whole stream.
This reverts commit eb2bdb706 "sidebar: Narrow to latest topic if
not in stream."  On a trial deploy, many users were surprised and
preferred the old behavior.
2017-12-11 16:35:12 -08:00
Rohitt Vashishtha eb2bdb706a sidebar: Narrow to latest topic if not in stream.
We now narrow to the latest topic in stream if we are narrowing from
outside the stream, and show all topics grouped together (previous
default) if we are already narrowed to the stream.

Fixes #7555.
2017-12-08 05:53:49 -08:00
Florian Jüngermann b31917be1d frontend: Remove redundant stream separator in the left sidebar.
In the case of no 'normal' streams (only pinned and dormant ones) there are two separators
between the groups of streams. My commit removes one.
2017-11-15 10:06:25 -08:00
Cynthia Lin 940ca17c46 hotkeys: Expand collapsed sidebars when sidebar searches are initiated.
Fixes #7351.
2017-11-14 11:12:13 -08:00
Cynthia Lin ead2a4c071 left sidebar: Prevent closing in responsive mode.
Fixes #2913
2017-09-08 11:20:36 -07:00
Tim Abbott 88e3ba9576 stream_list: Fix enter key to use data-stream-id. 2017-08-16 18:02:57 -07:00
Tim Abbott 047237e45b stream_list: Remove a reference to data-name in sidebar. 2017-08-16 18:02:56 -07:00
Steve Howell 57f17ae543 Extract top_left_corner.js.
Here are the functions in top_left_corner:

    get_global_filter_li: pure code move
    update_count_in_dom: simplifed copy of similar function in stream_list.js
    update_dom_with_unread_counts: pure code move, split out from function
       of same name in stream_list.js
    delselect_top_left_corner_items: pure code move
    handle_narrow_activated: pure code move + rename
    handle_narrow_deactivated: pure code move, split out from from function
       of smae name in stream_list.js
2017-08-14 13:03:57 -07:00
Steve Howell 0f3b565d40 Create explicit handlers for stream activate/deactivate.
Calling explicit functions ensurest that the sidebars
get activated for narrows before less important things
happen, and it also makes testing easier.
2017-08-14 13:03:57 -07:00
Steve Howell 8655fae910 Make deselect_top_left_corner_items() more accurate.
This function was actually de-selecting stream sidebar items
before.  Now we just explicitly de-select top-left items in it,
and we do stream-sidebar stuff in update_stream_sidebar_for_narrow().
2017-08-14 13:03:57 -07:00
Steve Howell 24e9dbe80b Use data-stream-id for zooming topics. 2017-08-11 13:01:39 -07:00
Steve Howell fad024ebda Simplify stream sidebar narrows.
This fix simplifies how we re-render topic lists when we
re-narrow or zoom out from a topic list.

    * The topic_list.zoom_out() no longer gets called as
      part of re-narrowing, and we eliminate the clear_topics
      option.

    * For all situations where we narrow to a filter that does
      not have a topic, we simply call the new function
      clear_topics().

    * The stream_list code no longer calls remove_expanded_topics()
      in cases where the new narrow has a topic.  This allows us
      to optimize away scroll/flicker churn a little more easily.

As part of this, we rename maybe_activate_stream_item() to
update_stream_sidebar_for_narrow(), since the function clears
stuff as well as turning stuff on.
2017-08-11 13:01:39 -07:00
Steve Howell 089670ac1c Extract stream_list.show_all_streams(). 2017-08-11 13:01:39 -07:00
Steve Howell d2686bdcdd Simplify maybe_activate_stream_item().
We extract get_sidebar_stream_topic_info() and just call
topic_list.rebuild() directly, which allows us to eliminate
rebuild_recent_topics().
2017-08-11 13:01:39 -07:00
Steve Howell cd4dd90641 Extract stream_list.update_top_left_corner_for_narrow().
This is mostly a pure code extraction.  It makes the call
to reset_to_unnarrowed() happen later in sequence.

The order of operations here is mostly unimportant, but
there may actually be some tiny user-facing benefit
in terms of having the logic happen more sequentially.

BEFORE:
    reset streams
    fix top left
    redraw streams

AFTER:
    fix top left
    reset streams
    redraw streams
2017-08-11 13:01:39 -07:00
Steve Howell c5d95a2db8 stream list: Rename method to scroll_stream_into_view.
The old name was scroll_to_active_stream, but it can be used
when pinning a stream, so "active" isn't necessarily accurate.
2017-08-11 13:01:39 -07:00
Steve Howell 9201137059 Fix scrolling glitches when zooming out to streams.
If you go into "more topics" for a stream with many topics,
and then scroll down, and then zoom out again with "All
streams", we make sure the active stream is still in view.
2017-08-11 13:01:39 -07:00
Steve Howell 9dd78c803c Make auto-scrolling less aggressive.
We have code that can automatically scroll an element into "view"
in its container.  We use this for stream sidebar rows inside the
stream list.

Generally the stream sidebar rows are small enough to fit into
the container, and the prior algorithm worked correctly for that
scenario.

If you have lots of topics, however, and a short screen, the
algorithm was being too aggressive.  For example, if the top
wasn't showing, it would scroll the top into view, but at the
cost of scrolling the bottom out of view.

This fix makes the general scrolling algorithm more tame.

Part of the user-facing problem is that the element we pass
into the scrolling code for the stream sidebar rows is bigger
than the part of the row that actually should be shown on
screen.  Nevertheless, it makes sense here to make the general
algorithm more robust.
2017-08-11 13:01:39 -07:00
Steve Howell c11c5c3795 Extract stream_list.scroll_delta() and add tests. 2017-08-11 13:01:39 -07:00
Steve Howell fe74e79a17 Rename subject_count -> topic_count.
This fixes all names in the JS codebase.
2017-07-31 08:04:20 -04: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 1ed35be88c stream_list: Use more direct code in build_stream_list.
We eliminate `.get(0)` calls in buld_stream_list.

The easy case is that we stop building jQuery objects
for the splitters only to pull out the DOM immediately.

The more subtle case is that we also don't do `.get(0)` calls
to get DOM out of our individual list items.  By passing
in full jQuery objects to `append()`, we should prevent ourself
from orphaning the old objects, which may in the future have
things like tooltip logic attached to them.
2017-07-18 09:58:16 -07:00
Harshit Bansal d3d6712fa3 left-sidebar: Update the size of the scrollbar after narrowing to a stream. 2017-07-03 09:53:41 -07:00
Steve Howell 29416c4b39 Move pm_list.set_click_handlers() call.
Instead of calling it from stream_list.initialize(), we
call it from the new pm_list.initialize().
2017-06-14 13:58:54 -04:00
Steve Howell 499962bb6b Change arg for stream_list.redraw_stream_privacy().
We now pass in a sub, not a stream name.
2017-06-14 11:24:42 -04:00
Steve Howell fb5d10af14 Extract stream_list.get_global_filter_li().
Now we use a consistent approach to find the list items for
Home/Starred messages/Mentioned in the upper corner.

In particular, we get rid of the complicated
iterate_to_find() function.
2017-06-14 09:27:50 -04:00
Steve Howell 7c2683d765 minor: Export stream_list.update_count_in_dom() for testing. 2017-06-13 18:37:02 -04:00
Steve Howell 79acbcd1bf Refine error handling for stream_list.get_stream_li calls.
We avoid false warnings in get_stream_li and for updating
unread counts.  We also early-exit for A/D keys if there is
no current stream.
2017-06-03 06:16:45 -06:00
Steve Howell 24d443a061 Have stream_list.get_stream_li() use stream_sidebar.get_row().
Given a stream id, we now find list items using the internal
data structures we created when we built the sidebar, rather than
using a jQuery selector.
2017-06-02 16:32:39 -07:00
Steve Howell ed49673555 stream_list: Use append() instead of appendTo().
Using append() is easier to unit test, and we avoid
creating a temporary jQuery object from the array
of sidebar rows.
2017-06-02 14:11:11 -07:00
Steve Howell fdea8f9334 Create stream_list.initialize(). 2017-06-02 14:11:11 -07:00
Steve Howell e7345bdd7f Improve error reporting in maybe_activate_stream_item.
This change should lead to clearer tracebacks when our
assumption about the stream list's list items get
violated, and we also short circuit some code in the
caller that tries to scroll to the active stream.
2017-05-30 21:26:55 -07:00
Steve Howell 561fba65d2 Remove spurious call to unread_ops.process_visible().
In stream_list.js we have some code to handle narrow activations,
and we were calling unread_ops.process_visible() only for
stream activations, not for PM-related activations, etc., so
our approach was inconsistent.

It also turns out that the call is redundant, since we call
unread_ops.process_visible() when the message pane scrolls as
part of updating the content.

Ideally, we want a more rigorous approach where we make this
call precisely when the new messages become visible to the user,
but the purpose of this fix is to de-clutter the stream_list
logic.
2017-05-30 21:26:55 -07:00
Rohitt Vashishtha 2d73e03e37 ui-refactor: Rename modals.js to overlays.js.
Fixed #4702.
2017-05-29 11:24:46 -07:00
Steve Howell 8eb9723283 stream_list: Call update_streams_sidebar() on renames.
If you rename a stream, call update_streams_sidebar() to
make sure we redraw the active stream correctly.
2017-05-15 14:47:41 -07:00
Steve Howell 76f68e9836 Fix buggy update_streams_sidebar().
If you were narrowed to an unpinned stream, and then pinned it,
we were mostly redrawing the sidebar correctly, but we weren't
setting the active-filter class.  Now we accomplish this by
calling maybe_activate_stream_item(), which also reduces some
code duplication.  (The new code introduces a bit of extra logic
to do `stream_li.addClass('active-filter')`.
2017-05-15 14:47:41 -07:00
Steve Howell 5b6bd6767b refactor: Extract stream_list.maybe_activate_stream_item(). 2017-05-15 14:47:41 -07:00
Steve Howell 1a11042fdf refactor: Use stream id more in topic_list.js. 2017-05-15 14:47:41 -07:00
Steve Howell 762194f98d Add stream_data.id_is_subscribed().
We use this function in stream_list.js.
2017-05-15 14:47:41 -07:00
Steve Howell 5d33d02235 Track unread counts using stream_id. 2017-05-15 14:47:41 -07:00
Steve Howell c125ba1d08 Fix how we find if streams are muted.
This commit changes stream_data.in_home_view() to
take a stream_id parameter, which will make it more
robust to stream name changes.

This fixes a bug.  Now when an admin renames a stream
you are looking at, it will correctly show itself to
be un-muted. (Even with this fix, though, the stream
appears to be inactive.)

Some callers still do lookups by name, and they will
call name_in_home_view() for now, which we can
hopefully deprecate over time.
2017-05-15 14:47:41 -07:00
Steve Howell d3a7aa3a37 Have get_stream_li() take a stream_id.
Rather than having get_stream_li() look up stream id using
stream name, we force the callers to pass in the stream id.

This adds an extra line to most of the callers for now, but
this will eventually change as we fix some of the callers to
have their callers pass in stream_id.

In places where we now call stream_data.get_stream_id() to
get the stream id, we will be more resilient toward stream
renamings, at least until the next reload, since
stream_data.get_stream_id() can resolve old names that
are stored when we process stream-rename events.
2017-05-15 14:47:41 -07:00
Steve Howell a48419310e Simplify get_filter_li() and get_stream_li().
We no longer have get_stream_li() delegate to get_filter_li(),
which simplifies the logic in get_filter_li() and makes
get_stream_li() more direct.

We also move the two functions closer to each other in the file.
2017-05-15 14:47:41 -07:00
Steve Howell 292b0ac64d Extract set_stream_unread_count. 2017-05-15 14:47:41 -07:00
Steve Howell cfdf256c62 refactor: Call get_stream_li() in a few places.
This is a step toward simplifying get_filter_li().
2017-05-15 14:47:41 -07:00