Commit Graph

134 Commits

Author SHA1 Message Date
Steve Howell 10bc093375 Stop using server data to draw "Manage Streams".
We have all the data we need on the client side.
2016-10-28 13:44:46 -07:00
Steve Howell 9d4debd1eb Live-update added/removed subscribers. 2016-10-28 13:43:09 -07:00
Tim Abbott 01f0be27a7 subs: Combine another set of settings show handlers. 2016-10-27 22:24:40 -07:00
Tim Abbott 426f2b0405 subs: combine some settings show handlers. 2016-10-27 22:22:28 -07:00
Tim Abbott 3fd94cc58a subs: s/subrow/sub_row/ in variable names. 2016-10-27 22:19:30 -07:00
Tim Abbott 12331e2596 subs: Extract show_subscription_settings. 2016-10-27 22:06:56 -07:00
Steve Howell 65a2f012d4 Simplify pin/unpin code path.
I make server_events slimmer by not handling a specific
property when subs.update_subscription_properties() should
do all the dispatching (and mostly did).

And then since update_subscription_properties() has
a "sub" already, I can call directly to stream_list code
and remove a function from subs.js.  Since I lose the
wrapper function in subs.js, I rename the stream_list
function as part of this commit.

The only code that gets slightly heavier here is that
we have two lines in the 'pin_to_top' case instead of one.
2016-10-25 23:29:15 -07:00
Steve Howell 1a927a424f Avoid passing around full_name parameter in subs.js.
All of the eventual callers to prepend_subscribers()
and format_member_list_elem() call people.get_by_email()
anyway, so now we do it one place.  The one exception
was using page_params.fullname, which is awkwardly
different than what we call that variable elsewhere
(fullname vs. full_name).
2016-10-25 18:15:24 -07:00
Steve Howell 51f0f7c7c4 Simplify creating subscriber list.
We were awkwardly reversing a list to use a one-line
helper method that did exactly the opposite of what
we wanted. :)  Now we just append simply.
2016-10-25 18:15:24 -07:00
Steve Howell 89b17ec2a4 Extract prepend_subscriber().
This is a minor change to avoid some 2-line calls in our
code.  (We're about to introduce a third usage of this.)
2016-10-25 18:15:24 -07:00
Tim Abbott 0f7c8c6d34 subs: Rerender subscriber counts from peer changes correctly.
This makes subscriber count management completely nice and real-time.
2016-10-25 14:40:24 -07:00
Steve Howell de727245aa subs: Add subscriber counts to the /#subscriptions page.
This borrows some work from krtkmj in #525.

Fixes #483.
2016-10-25 14:40:00 -07:00
sonali0901 1bc7990327 Extract people.filter_people_by_search_terms()
This code used to be in subs.js, but now it's in people.js and has
some unit tests.

I did this w/showell as part of live coding on Zulip.
2016-10-20 21:44:26 -07:00
Steve Howell 7fd74c45d7 Clean up startup code for streams.
The startup code in subs.js used to intermingle data
stuff and UI stuff in a loop inside a called function,
which made the code hard to reason about.

Now there is a clear separation of concerns, with these methods
being called in succession:

    stream_data.initialize_from_page_params();
    stream_list.create_initial_sidebar_rows();

The first method was mostly extracted from subs.js, but I simplified
some things, like not needing to make a copy of the hashes
we were passed in, plus I now garbage collect email_dict.  Also,
the code path that initialize_from_page_params() mostly replaces
used to call create_sub(), which fired a trigger, but now it
just does data stuff.

Once the data structure is built up, it's a very simple matter
to build the initial sidebar rows, and that's what the second
method does.
2016-10-17 19:58:23 -07:00
Steve Howell 869a124d7d Extract stream_data.get_streams_for_settings_page().
This function will make it easier to unit test upcoming
changes related to stream counts.

This was mostly moving code, but one change is that we
don't call create_subs() in subs.js any more (which would
have been kind of circular dependency), since the only thing
that it did besides calling a more appropriate function
in stream_data.js was to generate a trigger that was
subsequently ignored and possibly a UI trap, as we don't
want to be messing with the stream sidebar when we go into
the stream settings page.

We now simply call exports.create_sub_from_server_data() for
newly encountered unsubscribed streams (which don't belong in
the sidebar anyway.)
2016-10-17 19:58:23 -07:00
Steve Howell 965c6047db Move add_admin_options() to stream_data.js.
This function used to live in subs.js.  It's mostly a code move,
but I simplified the logic to determine whether it's subscribed
not to do a lookup into the same data structure that the sub
already came from.

I also added some tests.
2016-10-17 19:58:23 -07:00
Steve Howell cf08f04dbc Move receives_*_notifications() to stream_data.js.
This moves these functions from subs.js to stream_data.js:

    receives_desktop_notifications
    receives_audible_notifications

This makes notifications.js no longer dependent on the
bloated subs.js.
2016-10-17 19:58:23 -07:00
Steve Howell e25b67af26 Remove subs.sub_pinned_or_unpinned(). 2016-10-17 19:58:23 -07:00
Steve Howell 5dd1c2d55f Remove subs.stream_id(). 2016-10-17 19:58:23 -07:00
trueskawka aa7fd9a07c stream_creation: Add a clear error message for duplicate streams.
User is now unable to create a stream with duplicate or empty name
through the create stream modal. An appropriate error message appears
on attempt.
2016-10-16 12:59:41 -07:00
trueskawka 9c8f4d9a1e stream_filtering: Filter streams on subscriptions page.
Filter behaves similarly to filter in left sidebar, see PR #684. Added
stream input field to the stream creation modal along with other settings,
for clarity.

Fixes #455, #563.
2016-10-16 12:59:41 -07:00
Steve Howell dca5a3354e Extract stream_data.create_sub_from_server_data(). 2016-10-15 21:36:38 -07:00
Tim Abbott 0b7b15b361 subs: Reorganize encoding code a bit. 2016-10-14 12:34:01 -07:00
Tim Abbott eb5ef03ec0 subs: Encode stream names before changing stream names. 2016-10-14 12:34:00 -07:00
Mohsen Ibrahim 74baee93fa subs: Encode stream names before updating stream descriptions.
The API uses this endpoint /json/streams/<stream_name> to update
stream information such as description, since the stream_name is
part of the URI it should be encoded to escape unsafe characters.

Fixes #1986.
2016-10-14 12:33:55 -07:00
Kartik Maji 6d57e2a646 stream_data: Remove user from subscriber list on unsubscribe.
This fixes a bug where the .subscribers property of a subscription
object in stream_data wasn't being properly updated to remove the
current user when the current user unsubscribed from the stream.

Fixes #1667.
2016-10-11 18:19:03 -07:00
Tim Abbott 498317d533 Fix renaming streams on web to use new API.
In 142dce2cd4, we replaced the API for
renaming a stream, but failed to actually update the javascript to use
the new API.
2016-10-04 21:48:38 -07:00
Brock Whittaker f87c78d3f1 Add preview button to subscriptions page.
This adds a preview button to the subscriptions page to allow a user
to check out the stream without having to subscribe.

The button’s default state is hidden but on subscription row hover it
shows itself.

The preview button updates its text from "Narrow" to "Preview" and
back when a user subscribes and unsubscribes from a stream.

Fixes: #1519.
2016-09-19 22:13:47 -07:00
Brock Whittaker 64079b382f Channel popup unsubscribe button.
From the popups that appear when clicking the down-arrow in the left
column's streams, you can now unsubscribe from that particular
channel. This runs on the same function that unsubscribes you from
streams in the "Subscriptions" tab.

Fixes: #1554.

[tweaked by tabbott to fix some errors]
2016-08-26 20:22:11 -07:00
Brock Whittaker 5de33c94be Add padding to checkboxes and fix HTML.
The ‘for’ attribute is not valid HTML in the case of this because the
emails are invalid character sets and the input has no ID with the
email.

This changes it to a data-name which is still searchable but doesn’t
interfere with typical input behavior.

The checkboxes no longer float-left, fixing an issue with the
subscribe buttons leaning right in narrow windows.

Fixes: #1491.
2016-08-26 15:03:45 -07:00
Brock Whittaker e52d618f1b Switching from $.parseJSON to JSON.parse.
There are no modern browsers that do not have built in JSON parsing
abilities. We do not need $.parseJSON as it now just serves as a call
to JSON.parse.
2016-08-25 14:22:48 -07:00
Brock Whittaker 636d2df868 Convert misuses of attr to properly use prop.
Attr now returns “checked” instead of true and “” instead of false in
higher versions. This fixes those issues.

The attr(“data-*”) have also been covered to data() as well.
2016-08-25 14:22:28 -07:00
Tim Abbott 375551aaa6 Clean up most hardcoding of mit.edu domain checks.
This moves all this code to be gated on a few virtual realm settings.
2016-07-26 20:30:12 -07:00
Umair Khan 53662ccd11 Cache email address hint content.
This substantially improves the performance of loading the
/#subscriptions page with 1000+ streams in the realm.
2016-07-07 11:39:52 -07:00
Kartik Maji e5a3339725 Add search box for filtering users to add when creating new streams.
Fixes: #779.
2016-07-06 16:01:33 -07:00
Kartik Maji f8bb7503e6 Add ability to pin streams to top of the streams sidebar list.
Based on work by Lauren Long, with some tweaks by tabbott.
2016-06-30 22:26:09 -07:00
Umair Khan 939ebbbc98 Mark report_error arguments translatable. 2016-06-23 16:23:01 -07:00
Umair Khan 4da1a3ecd6 Mark report_success arguments translatable. 2016-06-23 16:23:01 -07:00
Umair Khan c61a3dfbcc Ensure translations are loaded.
Since i18next loads translations asynchronously we need to make sure
that they are loaded before we call the JS code which depends on them.

Fixes #982
2016-06-20 11:31:28 -07:00
Umair Khan 6fb0baaa25 Mark strings translatable.
Following strings are marked translatable:
- All strings which are passed to `button.text` or which affect the
    text of buttons.
- All strings passed to `placeholder`.
- All strings passed to `compose_error`.

Fixes #969
2016-06-13 09:03:56 -07:00
Tim Abbott 584887e588 lint: Require folding of } on same line in else if statements. 2016-06-09 14:05:34 -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
Kartik Maji 3d77aa49db Add subscribe button in narrowed view when stream has no messages.
A temporary message appears on successful subscription, with a button
offering to unsubscribe in case the user subscribed by accident.
2016-05-18 20:06:30 -07:00
Kartik Maji 206452c867 Add stream subscription button added narrowed views.
Fixes: #273
2016-05-18 20:06:23 -07:00
Ashish Kumar b5ab4d45f9 Replace /json/get_public_streams with REST style route. 2016-04-29 12:57:57 -07:00
Vishnu Ks ae49ad383d Rename all function on MessageList to all_messages. 2016-04-25 13:45:18 -07:00
Vishnu Ks 35b0af2852 Move all_msg_list to message_list.js. 2016-04-21 17:46:21 -07:00
Vishnu Ks 35f70e9dac Move 5 legacy global variables to pointer.js.
Move recenter_pointer_on_display, suppress_scroll_pointer_update,
fast_forward_pointer, furthest_read, and server_furthest_read to
a new pointer module in pointer.js.
2016-04-12 10:56:54 -07:00
Kumar 4eced69228 Make subscriptions page error bar visible even when scrolled down.
Previously, the Zulip subscriptions page's error bar would always be
at the very top of the scrollable view, and thus would likely be out
of view when an error happened.  This fixes it by having the error bar
always placed below the search box (and thus visible regardless of
where in the scrollable streams view we are).

Fixes: #515.

[commit message and comments expanded by tabbott]
2016-04-08 21:04:43 -07:00
Allie Jones 29a4b51e52 Replace /json/subscriptions/add usage with /json/users/me/subscription. 2015-12-12 18:14:08 -08:00