Commit Graph

4829 Commits

Author SHA1 Message Date
Steve Howell
45227e84fc refactor: Flatten code in subs.change_state(). 2018-12-02 19:07:13 -08:00
Steve Howell
84d0b541e3 hashchange: Add hashchange.update_browser_history().
This helps us encapsulate the situation where we don't
want to trigger hashchanged(), without having to do it
within sub.js with prevent_once().
2018-12-02 19:07:10 -08:00
Steve Howell
212ee015d4 refactor: Extract subs.switch_to_stream_row. 2018-12-02 18:40:00 -08:00
Steve Howell
bea328b8b6 refactor: Split out functions for opening edit panel.
While they can share some code, opening the edit panel
for a stream and clearing the panel are pretty different
actions, so we simplify the API for each thing.

You no longer have to pass in booleans, and for the clear
case, you don't have to pass in a bogus node that just
gets ignored.
2018-12-02 18:40:00 -08:00
Steve Howell
43f25eb4a5 Clean up code to open "Create stream" panel.
This fixes a bug where hitting the "n" hotkey was
causing double work related to the hashchange system.

The code is now organized like this:

    do_open_create_stream() does the GUI piece

    We call the above directly for hash changes.

    For in-app actions, whether clicks or hotkeys,
    we call open_create_stream(), which delegates
    most of the work to do_open_create_stream() but
    also updates the hash.
2018-12-02 18:40:00 -08:00
Steve Howell
13af91869d Deprecate unreachable code in hashchange.
The overlay URLs are never handled in this function,
and the prior code just created confusion.
2018-12-02 18:40:00 -08:00
Steve Howell
7859a441ac bug fix: Avoid spurious calls to subs.change_state.
This diff looks a bit more complicated than it really is.

We had a bug where we'd call subs.change_state for
non-streams-related changes.  The bug probably barely
impacted customers, since it's hard to get into that
situation unless you're in "Settings", and then the
code mostly did nothing.  There's still a deeper issue
of what we actually do want to for settings changes,
but this fix does not address that.

We invert the conditionals related to internal state
changes, so that we can handle internal state changes.

And we make sure to only call subs.change_state if our
"base" is "streams".
2018-12-02 18:40:00 -08:00
Steve Howell
b80de69932 hashchange: Rename ignore to state. 2018-12-02 18:40:00 -08:00
Steve Howell
4b6ae10fb7 Rename group to old_overlay_group. 2018-12-02 18:40:00 -08:00
Steve Howell
d11d1313d9 refactor: Flatten code for hashchanged().
Using early-exit make the 3 cases a bit more clear.

    opening overlay
    closing overlay
    "normal"
2018-12-02 18:40:00 -08:00
Steve Howell
1f41a65c88 Rename ignore.flag to is_exiting_overlay. 2018-12-02 18:40:00 -08:00
Steve Howell
cee29483cf hashchange: Extract hashchanged_overlay().
This is mostly extracting the code within the `if`
block, as well as setting `base`, which wasn't used
elsewhere.

Also, the `else` no longer calls `is_overlay_hash`,
which was a redundant check.
2018-12-02 18:40:00 -08:00
Steve Howell
20bbc375a5 Rename ignore.prev to ignore.hash_before_overlay. 2018-12-02 18:40:00 -08:00
Steve Howell
53e99c0a55 hashchange: Remove unused ignore.last. 2018-12-02 18:40:00 -08:00
Steve Howell
682235af80 Rename hashchange.should_ignore to is_overlay_hash. 2018-12-02 18:40:00 -08:00
Rishi Gupta
c59da02936 billing: Reflect discounts on /upgrade. 2018-11-30 11:19:07 -08:00
Rishi Gupta
1ba037201c billing: Move all price computations into billing.js. 2018-11-30 11:19:07 -08:00
Rishi Gupta
7523282e48 billing: Move cost calculation from upgrade.html to billing.js. 2018-11-30 11:19:07 -08:00
Rishi Gupta
60d3c17b6b billing: Enable tab navigation on /upgrade. 2018-11-30 11:19:07 -08:00
Steve Howell
b827efb461 refactor: Extract maybe_reset_right_panel(). 2018-11-29 20:09:24 -08:00
Steve Howell
c5b2cfd777 refactor: Extract get_search_params(). 2018-11-29 20:09:24 -08:00
Steve Howell
8f915da2ca refactor: Extract add_tooltips_to_left_panel(). 2018-11-29 20:09:24 -08:00
Steve Howell
3190c3ffeb refactor: Extract show_active_stream_in_left_panel(). 2018-11-29 20:09:24 -08:00
Tim Abbott
d0f71881f4 docs: Add detailed documentation on the process for sending messages.
This has long been something missing from our suite of documentation.
2018-11-29 16:25:35 -08:00
Steve Howell
d8c8fc1f03 streams: Optimize stream_data.create_sub_from_server_data.
This is definitely a micro-optimization, but avoiding
creating an extra object speeds up page loads by about
20ms per 1000 streams.

It's slightly sketchy to mutate the value in place, but
the original value never gets used again.
2018-11-29 13:29:17 -08:00
Tim Abbott
6781345b9b message_fetch: Fix a linter error introduced on rebase. 2018-11-29 13:29:12 -08:00
Steve Howell
ba243416e3 stream_color: Make stream color assignment more efficient.
We now let color_data keep its own state for
unused_colors, so that we longer have to pass in
a large list of unused_colors every time we want
to assign a new stream color.

This mostly matters at startup, where we might
be cycling through 5000 streams.  We claim all
the unused colors up front.

Each operation now has an upper bound of expensiveness,
where the worst case scenario is basically popping
off the first element of a list of <= 24 colors.

The algorithm is now deterministic, too, to make
it easier to test.  It's unclear whether random color
assignment ever had much benefit, and it made unit
testing the algorithm difficult.  Now we have 100%
line coverage.

Fixes part of #10902.
2018-11-29 13:00:25 -08:00
Shubham Dhama
990d7fb37d narrow: Remove narrow_activated.zulip event trigger. 2018-11-29 12:36:00 -08:00
Shubham Dhama
654c3240e4 narrow: Remove narrow_deactivated.zulip event trigger. 2018-11-29 12:36:00 -08:00
Shubham Dhama
42f1d2a33b tab_bar: Make explicit call of narrow change handle function. 2018-11-29 12:36:00 -08:00
Shubham Dhama
b726cd4b3e typing_events: Make explicit call of narrow change handle function. 2018-11-29 12:36:00 -08:00
Shubham Dhama
e908da7831 narrow: Remove some narrow_deactivated.zulip event handling. 2018-11-29 12:36:00 -08:00
Shubham Dhama
209dd6dd37 narrow: Extract processes needed to be executed after narrow deactivate. 2018-11-29 12:36:00 -08:00
Tim Abbott
83b127cec1 server_events: Extract functions for managing connection errors.
This cuts a bit of code duplication.
2018-11-29 12:31:08 -08:00
Shubham Dhama
01927fb470 message view: Fix hiding of connection-error message on narrowing streams.
When there is some error in connecting to server(more specifically to the
tornado server) the "Unable to connect to Zulip" connection error message
gets cleared as Django server could send the response of "get" request of
old messages and hence get_old_messages_success hides the error message
even though the connection is not properly established.

Fixes: #5599.
2018-11-29 12:26:41 -08:00
Tim Abbott
02f09e2473 settings: Fix linter errors with user profiles. 2018-11-28 19:29:33 -08:00
Tim Abbott
e39ebb7358 settings: Fix "Preview profile" button.
This was apparently broken in the refactoring in
a394778cde.
2018-11-28 16:46:15 -08:00
Yashashvi Dave
fe3270d2b9 input pills: Fix modal gets closed when user click on remove-pill-btn.
This commit fixes bug: When user clicks on remove-user-pill-btn,
it closes the parent modal instead of removing user pill from input.
This happens because button has class `exit` and there is click
event listener on all `exit` class buttons, which closes modal.

Fix this by adding `e.stopPropogation` to remove-user-pill listener.
2018-11-28 16:33:08 -08:00
Yashashvi Dave
28c38a44c8 static/js/popover: Use predefine func to append user pills in field.
This commit remove repetitive code to append user pills in
custom field of user profile popover. And call already defined
function there.
2018-11-28 16:22:35 -08:00
Yashashvi Dave
20b6d08ef7 static/js/settings_account.js: Extract append_custom_profile_fields. 2018-11-28 16:22:35 -08:00
Yashashvi Dave
b2aeffd947 static/js/settings_account.js: Extract intialize_custom_user_type_fields. 2018-11-28 16:22:35 -08:00
Yashashvi Dave
cd8f4dfac0 statis/js/settings_account.js: Extract initialize_custom_date_type_fields. 2018-11-28 16:22:35 -08:00
Balaji2198
16967d6761 static/js/settings_streams.js: Refactor delete_default_stream method. 2018-11-28 16:17:21 -08:00
Nikhil Kumar Mishra
478674a6d6 analytics: Refactor to support more than one tooltip on same page.
While we don't actually need another tooltip on /stats right now, this
provides a clear approach for how to do that.  We've since added
tooltips in various other parts of the webapp, and that code is pretty
copy-pasteable, so I think it's reasonable to say this closes #4612.

Cleaned up by tabbott to remove a bunch of unnecessary changes.
2018-11-28 16:04:35 -08:00
Steve Howell
6035304619 Extract color_data.js.
This code is pretty distinct from all the color-picking UI,
and we want to get it to 100% coverage and optimize it
more.
2018-11-28 14:51:51 -08:00
Tim Abbott
d8c5ad2a26 narrow: Add special text for conversation with yourself. 2018-11-28 11:59:16 -08:00
Abhinav Singh
0774bd7df0 portico: Fix password strength bar reset after form invalidation.
This code prevents the password bar from being incorrectly clear after
the sign up form is rendered again after invalid data is submitted
(generally due to forgetting to agree to ToS).

Fixes #10868.
2018-11-28 11:52:08 -08:00
Steve Howell
b79d63e9c3 copy/paste: Try to fix Casper flake and add comments.
I think this will fix a Casper flake where there was a race
window with multiple temp DOM elements holding copied text.

I also add a comment to the code I think causes this race
for the tests.
2018-11-27 21:42:16 -08:00
Tim Abbott
bddf23894d buddy list: Add marker for which user is yourself.
This helps make clear what's going on with the potentially confusing
"you" user.
2018-11-27 15:07:58 -08:00
Steve Howell
1890c30ee1 buddy list: Put "me" at the top of the list.
I think people will want this, particularly folks
with names toward the back of the alphabet.
2018-11-27 14:52:19 -08:00