Commit Graph

5004 Commits

Author SHA1 Message Date
Steve Howell b3594c984a message scrolling: Fix "Scroll down to view" warning.
We recently added a feature to warn users that they
may need to scroll down to view messages that they
just sent, but it was broken due to various complexities
in the rendering code path.

Now we compute it a bit more rigorously.

It requires us to pass some info about rendering up
and down the stack, which is why it's kind of a long
commit, but the bulk of the logic is in these JS files:

    * message_list_view.js
    * notifications.js

I choose to pass structs around instead of booleans,
because I anticipate we may eventually add more metadata
about rendering to it, plus bools are just kinda brittle.
(The exceptions are that `_maybe_autoscroll`, which
is at the bottom of the stack, just passes back a simple
boolean, and `notify_local_mixes`, also at the bottom
of the stack, just accepts a simple boolean.)

This errs on the side of warning the user, even if the
new message is partially visible.

Fixes #11138
2019-01-07 17:17:55 -08:00
Steve Howell 6f8da1bb27 Refactor: Split up add_messages api.
We now have two functions:

    add_new_messages
    add_old_messages

This is a lot easier on the eyes, and it will also
prevent us from exceeding line length in future commits.

We also remove an unneeded stub in the narrow_activate
tests.
2019-01-07 17:17:55 -08:00
Steve Howell 9a30b51e6e minor: Simplify maybe_add_narrowed_messages.
We eliminate the messages_are_new parameter, which
was always set to `true`.
2019-01-07 17:17:55 -08:00
Steve Howell 9893256668 message_events: Reorganize code to insert new messages.
This commit makes it a bit more explicit about
why we're updating 2 or 3 message lists every time.

It looks funny now to repeat the home-list updates
in both sides of the conditional, but this will be
more obvious in a subsequent commit, where we want
to capture return values from rendering.
2019-01-07 17:17:50 -08:00
Steve Howell ed0abb8a53 minor: Move code around for setting link id/text/class.
We don't need to compute these vars if we early exit.
2019-01-07 17:11:17 -08:00
Steve Howell a8fe6a864d message scrolling: Add started_scrolled_up logic.
Figuring out whether we started scrolled up
**BEFORE** rendering is more accurate than trying
to subtract out heights of new messages after
rendering.
2019-01-07 17:11:17 -08:00
Steve Howell 632262e484 message scrolling: Avoid zero-pixel animations.
In a recent commit we allowed for `scroll_amount`
to be zero (as an indirect consequence of letting
`scroll_limit` be zero without early exiting).

See 0f75be3e8e

We want to short circuit the call to
`system_initiated_animate_scroll`, partly to save
unnecessary computation, but in particular to avoid
invoking the suppress-pointer-update logic.
2019-01-07 17:11:17 -08:00
Steve Howell f1f7f72119 message scrolling: Add visible_bottom to info.
It's convenient to have visible_bottom as well
as top/height, and the extra computation is
trivial (it's just arithmetic, no extra jQuery
involved).

There's some minor cleanup here too.
2019-01-07 17:11:17 -08:00
Marco Burstein 9ddadd39f4 compose: Add support for using Zoom as the video chat provider.
This adds Zoom call properties to the `Realm` model, creates endpoints
for creating calls, adds a frontend and tests.

Fixes #10979.
2019-01-07 10:00:02 -08:00
Yashashvi Dave 4bfea4cebe subscriptions: Hide add-subs html element if user is guest user.
Guest users can not add subscribers to subscribed or unsubscribed
streams. Therefore hide add-subs html element if current user
is guest user.

Tweaked by tabbott to use the early-return pattern.
2019-01-05 16:24:39 -08:00
Yashashvi Dave e8fbd855e6 subscriptions: Add tooltip, only subscribers can add user in private stream.
Add explanation in popover on disabled add-subscriptions input elements,
admin can't add subscribers to non subscribed private streams, only
subscribed users can.

Fixes #10593
2019-01-05 16:21:41 -08:00
Steve Howell efc1c74792 message scrolling: Move early-exit code higher.
This avoids some unnecessary computation and will
simplify testing.
2019-01-05 15:33:20 -08:00
Steve Howell 0f75be3e8e message scrolling: Extract _scroll_limit().
There's a subtle change here in how we handle the
hypothetical case that the selected message is above
the top of the feed.  Instead of early-exiting
from _maybe_autoscroll(), we just treat the limit
as zero, which will have the same effect.

We also change a var name be just `scroll_limit`
instead of `available_space_for_scroll`.  A longer
name would be valuable if it were somehow more
specific, but it was needlessly verbose.
2019-01-05 15:33:20 -08:00
Steve Howell a7c92a2590 message scrolling: Extract _new_messages_height(). 2019-01-05 15:33:20 -08:00
Tim Abbott 0c6175f27e lint: Enforce semicolon spacing in eslint.
We only had a few exceptions to this rule; the zjquery one was actually a bug.
2019-01-05 15:31:30 -08:00
Harshit Bansal 194dd5fd30 emoji: Remove now unused `emoji.emojis` data structure. 2019-01-05 15:09:04 -08:00
Harshit Bansal 25229ffeea emoji: Merge datasources for emoji picker and typeahead.
This will help us in avoiding a lot bugs where some emojis were
present in emoji picker and not in typeahead and vice-versa.
2019-01-05 15:09:04 -08:00
Harshit Bansal f8f971bfd6 typeahead: Rename `codepoint` to `emoji_code`. 2019-01-05 15:09:04 -08:00
Harshit Bansal 4251543426 emoji.js: Add `display_name` field.
The idea is to use this field for storing the best matching alias
to be displayed in search results. In subsequent commits I will
replace the search and rendering logic to use this field instead
of creating new objects on each search.
2019-01-05 15:09:04 -08:00
Tim Abbott d1b189b2cd settings: Fix casper tests on invitations page.
We don't allow arrow functions in the codebase yet.
2019-01-05 15:08:37 -08:00
Shubham Dhama e26cba062b settings_invites: Add invited_as column to the table.
This makes it possible to review the roles used in active invitations.
2019-01-05 14:53:09 -08:00
Shubham Dhama 42c262b807 invite: Replace `invite_as_admin` usage with `invite_as`.
Since we have already added the `invite_as` field to models, we can now
replace usage of `invite_as_admin` properly with its equivalent `invite_as
== PreregistrationUser.INVITE_AS['REALM_ADMIN']`.

Hence, also removed now redundant `invite_as`.
2019-01-05 14:46:38 -08:00
Amadeo234 e07ad67624 message-edit: Add press to Enter to Save edited message functionality.
This couples the behavior of Enter to Save with Enter to Send.
Extracts and exports functions responsible for checking if enter
does send/edit and handling default behavior otherwise.
Changes made in static/js/message_edit.js and
static/js/composebox_typeahead.js

Fixes #10320.
2019-01-04 11:59:15 -08:00
Amadeo234 e06867fec3 message-edit: Extract functions concerning Enter to Send.
This adds two functions to static/js/composebox_typeahead.js.
should_enter_send(event) checks if enter should actually send.
handle_enter(textarea,event) emulates browser's default behavior
if enter doesn't send.

These two are just straight extractions of portions of the compose box
logic.
2019-01-04 11:58:56 -08:00
Steve Howell d844a070fd ui: Render feedback widget client side.
We re-render the feedback widget on every call to
show().  This allows us more flexibility to mess
with the markup for particular use cases.
2019-01-04 10:54:10 -08:00
Steve Howell c3a0a22661 slash commands: Add undo for /day and /night.
This also works for the synonyms /light and /dark.
2019-01-04 10:54:10 -08:00
Steve Howell 995a26f4e5 ui: Explicity initialize night mode. 2019-01-04 10:54:10 -08:00
Steve Howell bdd7a64d19 ui: Close feedback widget with escape key.
It's a bit dangerous for the user to hit escape
to close the feedback widget, since it can
disappear suddenly, but users will try it, and
we should just close the widget.

(Hitting escape should be a noop if the box
is closed, but now it goes to "All Messages".)
2019-01-04 10:54:09 -08:00
Steve Howell 1cbcb06157 ui: Extract feedback_widget module. 2019-01-04 10:54:07 -08:00
Steve Howell 4468311620 feedback widget: Avoid duplicate handlers.
We only need these once, not during every show()
call.  We actually were only setting up the
click handlers one time, but we had redundant
mouse handlers.

More importantly, we stop a runaway timer
that tries to fade out our feedback widget
every 100ms or ten times per second!
2019-01-04 10:49:19 -08:00
Steve Howell 39cdc926a5 muting: Simplify dismiss() method. 2019-01-04 10:49:17 -08:00
Steve Howell 4baa65f38a muting: Rename container template to feedback_widget.html.
We now load the specific content for unmuting from
a handlebars template.
2019-01-04 10:48:19 -08:00
Steve Howell 0c48dad1da muting: Use more generic markup for undo-mute popup.
This makes everything generic except for the main
message given to the user.
2019-01-04 10:40:05 -08:00
Steve Howell 425df1c905 muting: Extract notify_widget class.
A few things are still hard coded, but the class exposes
show() and dismiss() now.

The show() method is configured with callbacks for
populate() and on_undo().
2019-01-04 10:40:02 -08:00
Steve Howell 51438281c7 minor: Rename $mute to $container.
The name doesn't even make sense for the specific
case, and we want to generalize this widget.
2019-01-04 10:37:31 -08:00
Vishnu Ks 2547d4ea07 billing: Remove mix option from frontend. 2019-01-04 23:52:00 +05:30
Vishnu Ks c1551405aa billing: Extract setting initial tab into helpers.js. 2019-01-04 23:52:00 +05:30
Vishnu Ks d94b0da3c8 billing: Separate billing.js into multiple modules. 2019-01-04 23:52:00 +05:30
Vishnu Ks 343e124270 billing: Remove get_form_input function. 2019-01-04 23:52:00 +05:30
Steve Howell 56ee70e2a9 refactor: Re-organize some logic in message view.
We calculate a few values higher up in the function.
This reduces a bit of code duplication and removes
a somewhat janky expression that happens against
a mutated list.
2019-01-03 17:33:47 -08:00
Steve Howell b88c3cd0d4 refactor: Rename vars in floating_recipient_bar.js.
The "label" made it sound these vars are strings, when
they are actually jQuery objects.
2019-01-03 17:33:44 -08:00
Steve Howell 78a3cb5887 Extract helper functions in floating_recipient_bar.js.
I use shorter var names in frb_botom() and do early
return in obscured_recipient_bar().

Also, we always call exports.hide() if we don't find
a valid recipient bar to "float."
2019-01-03 17:28:58 -08:00
Steve Howell f985125eb0 js: Initialize people.js earlier.
There is no reason not to initialize people.js
super early in the process, as it only reads
data from page_params.  Also, other modules
are likely to want its data during their own
initialization steps.
2019-01-03 13:49:44 -08:00
Steve Howell 5a313ccb90 presence: Use people.is_my_user_id() for check.
This is the preferred way to check that a user
id belongs to the current user.

We have a recent bug where the current user's
circle doesn't turn green right away.  It's not
clear this is the fix, though.  (It's hard to
repro locally.)
2019-01-03 13:49:44 -08:00
Steve Howell 6b7a4f8611 tests: Add unit tests for ui_init.js.
This test tries to find obvious dependency bugs, but
it really doesn't do anything other than fail when
it tries to use unavailable resources.
2019-01-03 13:44:38 -08:00
Tim Abbott a1919971e4 import: Handle invalid data-user-id values for mentions.
This is an issue with zulip -> zulip server data imports.
2019-01-02 15:23:09 -08:00
Shubham Dhama 092b73d0b7 ui: Fix wrong usage of scrolling to top in ui.updateScrollbar.
This was a bug introduced in 2363c9955a.

Fixes: #11141.
2019-01-02 11:00:01 -08:00
Steve Howell 7b5f282aee status: Show "(away)" next to yourself if you're away. 2019-01-02 09:27:16 -08:00
Steve Howell cb691694d1 status: Add user menu options to set/revoke away status. 2019-01-02 09:23:20 -08:00
Steve Howell 6507804637 status: buddy list: Add basic UI to show away status.
Right now we do very simple things:

    you: make the green circle empty

    them: make the circle empty and demote to last group
2019-01-02 09:23:19 -08:00