Commit Graph

85 Commits

Author SHA1 Message Date
Anders Kaseorg 6ec808b8df js: Add "use strict" directive to CommonJS files.
ES and TypeScript modules are strict by default and don’t need this
directive.  ESLint will remind us to add it to new CommonJS files and
remove it from ES and TypeScript modules.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-31 22:09:46 -07:00
Aman Agrawal b34d46e00b css: Rename #home id to #message_feed_container. 2020-07-28 16:33:32 -07:00
Anders Kaseorg f0c4cc9e46 js: Fix new import/order errors.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-24 13:04:07 -07:00
Steve Howell cc31403112 mobile sharing: Move fenced_code.js to shared/js.
We also take fenced_code out of the global namespace,
since it only requires katex and underscore.

And we fix the exports to be ES6 style.
2020-07-24 12:57:52 -07:00
Anders Kaseorg 96dcc0ce6e js: Use ES6 object literal shorthand syntax.
Generated by ESLint.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-21 12:42:22 -07:00
Tim Abbott 9b8255d741 compose: Rename blur_textarea to better describe its purpose.
This blurs all the input elements in the compose area, not just the
textarea for the message body.
2020-07-21 12:08:40 -07:00
Gittenburg ed5a56ce53 composebox: Blur PM recipient input after close.
Previously the private_message_recipient input remained focused after
closing the composebox with Escape. On Firefox this resulted in it
gobbling up all further keyboard shortcuts until you clicked
somewhere. On Chromium this bug didn't occur because it automatically
blurs hidden inputs.

Introduced in 3a1bf04a56.

Fixes #15849.
2020-07-21 12:02:31 -07:00
Anders Kaseorg a9ca5f603b js: Replace deprecated jQuery event trigger shorthand.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-21 12:01:26 -07:00
Anders Kaseorg b65d2e063d js: Reformat with Prettier.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-17 14:31:25 -07:00
Anders Kaseorg f3726db89a js: Normalize strings to double quotes.
Prettier would do this anyway, but it’s separated out for a more
reviewable diff.  Generated by ESLint.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-17 14:31:24 -07:00
Anders Kaseorg 4d04fa3118 compose: Rewrite Zoom video call integration to use OAuth.
This reimplements our Zoom video call integration to use an OAuth
application.  In addition to providing a cleaner setup experience,
especially on zulipchat.com where the server administrators can have
done the app registration already, it also fixes the limitation of the
previous integration that it could only have one call active at a time
when set up with typical Zoom API keys.

Fixes #11672.

Co-authored-by: Marco Burstein <marco@marco.how>
Co-authored-by: Tim Abbott <tabbott@zulipchat.com>
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2020-06-03 16:39:12 -07:00
Steve Howell 9489960b73 dead code: Remove useless resize calls.
We had a bunch of places where we
were calling `resize.resize_bottom_whitespace`
with no arguments, which has been a no-op
since the below commit that removed support
for our `autoscroll_forever` option:

    fa44d2ea69

With the `autoscroll_forever` options things
like opening/closing the compose box could
alter how much bottom whitespace you'd want,
but we stopped supporting that feature in
2017.

Since then bottom_whitespace has just always
been 40% of the viewport size.  So we only need
to change it on actual resize events.

It's worth noting that we still call
`resize_bottom_whitespace` indirectly in many
places, via `resize_page_components`, and
the latter actually causes
`resize_bottom_whitespace` to do real work,
but that work is redundant for most of those
codepaths, since they're not triggered by
changes to the viewport.  So there are other
opportunities for cleanup.
2020-05-27 17:57:50 -07:00
Aman Agrawal 7c502acb4c message_edit: Show stream color bar alongside stream select.
* Stream bar color logic is borrwoed from compose stream bar.
* Use flex containers to align elements and automatically set their
  height to be same, them automatically filling the stream color bar
  height to be the height of the select box.
* Use flex-wrap to wrap the propagate selector when out of space.

* To make sure stream select box and stream color box are closest possible,
  select box has been moved under stream color box.
2020-05-14 14:27:53 -07:00
Aman Agrawal 9734bcc7cd compose_ui: Extract method to set color of stream header bar.
Similar method will be used to set color for stream selection bar
when editing stream of topic/message.
2020-05-14 14:27:53 -07:00
Anders Kaseorg dbffb2a614 js: Convert _.extend to spread syntax or Object.assign.
This is not always a behavior-preserving translation: _.extend mutates
its first argument.  However, the code does not always appear to have
been written to expect that.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-02-25 14:09:39 -08:00
shubhamgupta2956 efda2684ea util: Replace util.get_message_topic().
Replace `util.get_message_topic(message)` with `message.topic`.

Fixes #13931
2020-02-21 09:53:45 -05:00
Steve Howell 9ab07d1038 util.js: Remove util from window.
We now treat util like a leaf module and
use "require" to import it everywhere it's used.

An earlier version of this commit moved
util into our "shared" library, but we
decided to wait on that.  Once we're ready
to do that, we should only need to do a
simple search/replace on various
require/zrequire statements plus a small
tweak to one of the custom linter checks.

It turns out we don't really need util.js
for our most immediate code-sharing goal,
which is to reuse our markdown code on
mobile.  There's a little bit of cleanup
still remaining to break the dependency,
but it's minor.

The util module still calls the global
blueslip module in one place, but that
code is about to be removed in the next
few commits.

I am pretty confident that once we start
sharing things like the typeahead code
more aggressively, we'll start having
dependencies on util.  The module is barely
more than 300 lines long, so we'll probably
just move the whole thing into shared
rather than break it apart.  Also, we
can continue to nibble away at the
cruftier parts of the module.
2020-02-15 12:20:20 -08:00
Steve Howell b8f01f9cda people: Rename method to get_by_user_id().
This name is consistent with:

    get_by_email()
    get_by_name()
2020-02-05 12:04:56 -08:00
Rohitt Vashishtha f4b02ce31e compose: Add fences of unused length in quote-and-reply.
When quoting a message with fenced code blocks without a language,
we used to have ambiguity in which '```' fence terminates the quote.

This commit adds explicitly non-interfering fences, which fixes the
above issue as well as makes the raw message easier to quickly read.

Fixes #12446.
2020-02-04 18:17:47 -08:00
Rohitt Vashishtha f5990ccbff compose: Add message info with quote-and-reply.
This adds the original message's sender name along with a
link to narrow to that message when using quote-and-reply.

Fixes #11568.
2020-02-04 18:17:47 -08:00
Tim Abbott 8b55a310f1 typing: Fix invalid typing notifications for stream messages.
In e42c3f7418, we made the assumption
that compose_pm_pill.get_recipient() would return no users for stream
messages.  It turns out, due to the confusing name of
compose_state.recipient (which we just renamed to
compose_state.private_message_recipient), this assumption was wrong.

As a result, when composing a stream message using the reply hotkeys,
we'd end up sending typing notiifcations to the person who sent the
message we're replying to as though a PM was being composed.

We fix this by avoiding passing an (expected to be unused) value for
private_message_recipient to compose_state.start.
2019-12-02 09:31:16 -08:00
Tim Abbott ea7c6d395f compose_state: Rename compost_state.recipient to be about PMs only.
The compose_state.recipient field was only actually the recipient for
the message if it was a private_message_recipient (in the sense of
other code); we store the stream in compose_state.stream instead.

As a result, the name was quite confusing, resulting in the
possibility of problematic correctness bugs where code assumes this
field has a valid value for stream messages.  Fix this by changing it
to compose_state.private_message_recipient for clarity.
2019-12-02 08:53:55 -08:00
Anders Kaseorg 28f3dfa284 js: Automatically convert var to let and const in most files.
This commit was originally automatically generated using `tools/lint
--only=eslint --fix`.  It was then modified by tabbott to contain only
changes to a set of files that are unlikely to result in significant
merge conflicts with any open pull request, excluding about 20 files.
His plan is to merge the remaining changes with more precise care,
potentially involving merging parts of conflicting pull requests
before running the `eslint --fix` operation.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-11-03 12:42:39 -08:00
Anders Kaseorg 4d37dfcf85 js: Convert vars declared separately and assigned once to const.
Because of the separate declarations, ESLint would convert them to
`let` and then trigger the `prefer-const` error.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2019-10-28 15:02:43 -07:00
Anders Kaseorg d17b577d0c js: Purge useless IIFEs.
With webpack, variables declared in each file are already file-local
(Global variables need to be explicitly exported), so these IIFEs are
no longer needed.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2019-10-25 13:51:21 -07:00
YashRE42 7a6f4630dc compose_box: Prepopulate stream if possible.
When users are only subbed to a single stream, this autofills the stream
field of the compose box.
Fixes #12507.
2019-07-31 10:20:24 -07:00
Vinit Singh 03180752db compose: Update placeholder text depending on the narrow.
Change the `compose-textarea` placeholder text depending on the
stream/topic or PM recipients that the message will be sent to.

Resolves #12834.
2019-07-29 15:51:50 -07:00
Vinit Singh 86073588be dependencies: Upgrade jquery-autosize 1.17.7 to autosize 4.0.2.
The API for the autosize library changed upstream, so several changes
had to be made to relevant js files for a successful upgrade.

Resolves #12695.
2019-07-18 14:33:16 -07:00
Mohit Gupta 6ec40cf9a0 search: Don't mark messages as read in search narrow.
Don't mark unread messages as read while searching.
This behavior will be extended to other narrows later.

Fixes: #12556.
2019-07-17 17:58:20 -07:00
Rishi Gupta 99ea5f4e32 popovers: Remove a few entries from stream popover.
These options are pretty low-value, since clicking the stream does the
narrow, and it's likely that almost nobody sends messages via these
buttons.
2019-03-06 17:36:06 -08:00
Tim Abbott 309aef4c27 compose: Fix "You need to scroll" notifications for large messages.
When you just sent a large message, our logic for "you need to scroll"
notifications did not correctly take into account the height of the
compose box.  This was easily reproduced when sending very long
messages.  The correct solution requires a bit of math to compute what
the visible area will look like after the compose box is closed.

This should be the final fix to #11138.
2019-02-05 13:17:10 -08:00
Steve Howell 01d9a3b02c quote/reply: Leave message intact for IE/Chrome.
We had a bug where if you started typing a message
and then used quote/reply (after the fact), we
would overwrite the user's original message.

The bug was kind of subtle--the internal call
to "respond" to the message would select the message
text, and then `smart_insert` would replace the
selection, unless it was Firefox.

Note that we now also allow you to cross-post
replies, which is a plausible scenario, although
possibly unintentional at times, too.  I'm erring
on the side of giving the user control here, but
I'll add a warning in the next commit.  Our compose
fade feature should also prevent unintentional
mixes here, too.
2019-01-23 10:57:40 -08:00
Steve Howell 664ee8d017 quote/reply: Dedup some logic with replace_content().
We often need to go to the server to get raw content.
The exceptions are messages for which we've already
fetched the raw content for some other reason (maybe
a previous quote-and-reply) or which are locally echoed.

Whether we can get the raw content locally or from
the server, the replace_content() logic is the same.
2019-01-23 10:57:40 -08:00
Steve Howell 4b2181ffa2 Rename util.get_topic -> get_message_topic().
The specific name will help us when we fully cut
over to "topic" on message objects.
2018-12-29 11:38:39 -08:00
Tim Abbott bdb3da4504 eslint: Add key-spacing linter rule.
Apparently, we didn't have one of these, and thus had a moderate
number of generally very old violations in the codebase.  Fix this and
clear the ones that exist..
2018-12-18 10:41:06 -08:00
Steve Howell 35b904b184 subject -> topic: Fix subject in opts.
It's kinda difficult to track down all the interactions
with the opts that go through compose_actions.start(),
but I think I got everything.
2018-12-16 11:26:18 -08:00
Steve Howell d7aa5fcc38 compose: Remove obsolete references to replying_to_message.
The `replying_to_message` field was used in some
early versions of compose fade, but it has no more
use in the current code.

The drafts implementation didn't really make any sense,
anyway, as we were claiming to reply to the same
message we were drafting.
2018-12-16 11:26:02 -08:00
Steve Howell d7c2577ffb subject -> topic: Rename compose fields.
The stream/topic edit areas now have these ids:

        #stream_message_recipient_stream
        #stream_message_recipient_topic

They are pretty verbose, but being able to grep
for these without noise does have some value.
2018-12-09 21:28:45 -08:00
Rohitt Vashishtha ee3b4f3ee9 hotkeys: Map `CTRL + .` to narrow to compose box target.
Also adds relevant tests and documentation. We currently
do not narrow to a new topic, and instead just narrow to
the stream. Similarly, we do not narrow to a PM if any of
the recipients are invalid.
2018-12-04 13:58:00 -08:00
Steve Howell 68d81cb25b subject -> topic: Fix respond_to_message(). 2018-11-16 11:11:40 -08:00
Tim Abbott 86801d350a compose: Store raw_content after fetching it for quoting.
This is a nice performance optimization for the rare case where the
user does quote-and-reply on a message, aborts the compose, and then
re-does the quote-and-reply.
2018-11-14 23:55:26 -08:00
Marco Burstein f37e4df471 compose: Check if `raw_content` is present when quoting.
If `raw_content` is already present for the selected message, there is
no need to make a request to the server.
2018-11-14 23:52:08 -08:00
Steve Howell b615f0df4d subject -> topic: Fix stream/subject in comments. 2018-11-14 23:24:06 -08:00
Rohitt Vashishtha d7a0bd4a6c subject-to-topic: Add topics to compose_state.js. 2018-11-14 23:24:06 -08:00
Marco Burstein 207d7a8ee6 compose: Use a placeholder when quoting and replying.
Use the placeholder `[Quoting…]` when quoting and replying before the
quote has been added to the message. Also, add tests to the
`compose_actions` Node tests for the new behavior.

Fix #10705.
2018-11-07 09:56:38 -08:00
Rohitt Vashishtha 38cddf7d54 compose_actions: Use people.get_mention_syntax in reply_with_mention. 2018-10-13 16:42:50 -07:00
Steve Howell eb676e8e50 Add more space between compose box and selected message.
When we nudge up the feed to prevent the compose box
from obscuring it, we now have 20 pixels of separation
instead of 5.  Before this fix, it was hard for users
to know whether they had any messages being covered.
2018-08-29 14:26:48 -07:00
Steve Howell 9f3b71b0b8 Adjust the message feed for long messages.
We now have a callback for whenever the compose
box gets autosized by our old vendored version
of the autosize widget.  It calls code to
scroll up the message feed if we are newly
covering it.
2018-08-28 13:50:19 -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 bec40af614 Remove redundant narrow_state.get_current_filter().
We now use narrow_state.filter() everywhere.  The
two functions did the same thing, and I slightly
prefer the concise name, which was already in use
in lots of places.
2018-07-10 14:20:24 +05:30