Commit Graph

8860 Commits

Author SHA1 Message Date
Steve Howell b0cd7e02b6 stream create: Remove obsolete markup.
The only place we were using data-stream-name was
the Casper tests, which was fixed in the prior
commit.

And we don't need the value either.
2020-01-28 14:49:57 -08:00
Tim Abbott 0c0b446d43 templates: Reorder conditionals for stream_settings_checkbox.
This makes the template actually readable.
2020-01-28 14:26:53 -08:00
Tim Abbott b234c52699 templates: Wrap stream_settings_checkbox. 2020-01-28 14:23:47 -08:00
Tim Abbott 7af6be9aaf subs: Fix reloading the browser to "manage streams" UI.
I'm not sure when this regressed, but the bug is one of those subtle
"8" != 8 issues.

Fixes #13756.
2020-01-28 14:17:29 -08:00
Pragati Agrawal b2c71b7cd8 stream edit: Move realm_setting_disabled in settings context.
Basic intention for this change is just to make code clean and intuitive.
2020-01-28 14:09:07 -08:00
Pragati Agrawal ada37a10f4 stream edit: Move logic for disabled checkboxes from template to js.
In templates we determine checkboxes are disabled by using the following
`if` clause,
```
{{#if (or (and is_muted notification_setting) realm_setting_disabled)}}
disabled="disabled"
{{/if}}
```
and it is more intuitive to do such calculation in javascript code, so we
added an `if_disabled` attribute in `settings` context which replaces
logical operations from `if` statement.

So for non-notification settings, it is
```
is_disabled: check_realm_setting[setting]
```
where check_realm_setting[setting] is same as realm_setting_disabled.

and for notifiaction settings it is,

```
ret.is_disabled = check_realm_setting[setting] || sub.is_muted;
```
2020-01-28 14:09:07 -08:00
Pragati Agrawal b862184d23 stream edit: Move is_checked calculation of stream settings in js.
It is more intuitive to do logical operations in js code instead of
templates and it is also cleaner.
2020-01-28 14:09:07 -08:00
Pragati Agrawal fd09111d8d stream_edit: Minor refactoring of stream_edit.stream_settings function.
The primary reason for this refactor is `.map` is more suitable in this
context instead of `_.each`.
2020-01-28 14:09:07 -08:00
Pragati Agrawal 0059624449 stream settings: Remove redundant arguments as a context to template.
This removes redundant arguments passed to `stream_settings_checkbox`
template from `subscription_settings`.
2020-01-28 14:09:07 -08:00
Tim Abbott 0fa67c84d8 hotkey: Optimize processing_text.
Profiles of typing in the Zulip webapp's compose box after opening the
stream creation widget showed that hotkey.processing_text was a
significant expense.  There's no good reason for this -- the function
just needs to inspect the focused element; it just was written with a
sloppy selector.

While there's a secondary issue that, there's no good reason for this
extremely latency-sensitive code path (typing an additional character)
to be doing something extremely inefficient.
2020-01-28 16:47:56 -05:00
Steve Howell 67a3af4d88 emojis: Make it easier to type smiley icons.
We now give "slight smile" precedence over
"small airplane" if you type "sm".

More generally, we favor popularity over prefix
matches for emoji matches, as long as the popular
emoji matches on any of its pieces.
2020-01-28 12:48:02 -08:00
Steve Howell a87798bb8e refactor: Use Set for popular emojis. 2020-01-28 12:48:02 -08:00
Steve Howell 345fcd3a69 mobile sharing: Move sort_emojis into typeahead. 2020-01-28 12:48:02 -08:00
Steve Howell 011d52470c refactor: Move popular_emojis to typeahead library.
I removed a slightly confusing code comment, which I
will address in a follow up commit.  Basically,
"slight smile" still doesn't win over "small airplane"
when you search for "sm", which kind of defeats the
purpose of having popular_emojis for the typeahead
use case.  This is a problem with sort_emojis, though,
so when the comment was next to the list of popular
emojis, it wasn't really actionable.
2020-01-28 12:48:02 -08:00
Steve Howell 16ae53890b refactor: Move util.prefix_sort to typeahead.triage. 2020-01-28 12:48:02 -08:00
Steve Howell c2e6423b41 marked: Use startsWith instead of indexOf.
We are sweeping the codebase to use startsWith
when possible.  I kept this on a separate
commit due to us vendoring the library, just
to reduce some noise.
2020-01-28 12:48:02 -08:00
Steve Howell d0453dc8f4 performance: Use startsWith in many places.
Using startsWith is faster than indexOf, especially for long strings
and short prefixes.  It's also a lot more readable.  The only reason
we weren't using it was when a lot of the code was originally written,
it wasn't available.
2020-01-28 12:47:37 -08:00
Steve Howell d3e961e179 performance: Improve prefix_sort.
We only convert the query to lowercase outside the
loop for an Nx speedup, where N = number of items.

And then we use startsWith instead of indexOf, which
means we don't senselessly search entire strings
for matches.

(We've had startsWith polyfills for a while now.)

Unfortunately, unless a string start with the
exact casing of the query, we still create an
entire lowercase copy of the string for the case
insensitive match.  For the English use case
(and many other languages), we could further
optimize this by slicing the string before
converting it to lowercase.

Unfortunately, you have languages like German
with the straße/STRASSE problem.  It's not clear
to me how we handle them with the current code,
but I don't want to break that yet.
2020-01-28 13:49:03 +00:00
Steve Howell 10e75e6df5 refactor: Clean up prefix_sort get_item usage.
We use the nice es6 syntax to create the get_item
helpers (in the callers and for the default
value in the function).

Also we use better es6 style for the looping.
2020-01-28 13:07:25 +00:00
Steve Howell 162cb27690 emoji sort: Inline helper function. 2020-01-28 12:04:11 +00:00
Tim Abbott 56b49e5566 invite: Fix capitalization for 'receives new stream notifications'.
Caught by out i18n capitalization linter.
2020-01-27 17:06:51 -08:00
Steve Howell 4125eb28fd mobile sharing: Extract shared/js/typeahead.js.
This extracts get_emoji_matcher and all the
functions it depended on, most of which were
in composebox_typeahead.js.

We also move remove_diacritics out of the people
module.

This is the first major step for #13728.
2020-01-27 16:32:11 -08:00
Tim Abbott c2ab63094d invite-user: Adjust default size of the emails text area.
It looks cleaner starting with full page width.
2020-01-27 15:37:00 -08:00
Hashir Sarwar 13b3eb24b0 invitations: Avoid adding to notifications stream unconditionally.
Adding invited users to the notifications stream unconditionally isn't
a correct behaviour for guest users, where the previous behavior of
including the notifications stream no longer makes sense. Therefore,
while inviting a new user, the notifications stream is listed along
with other streams with a message "recieves notifications for new
streams" in order to distinguish it from other streams.

Fixes #13645.
2020-01-27 15:36:59 -08:00
Steve Howell 05f1c6983b stream create: Avoid unnecessary val attribute.
We used to put the user's email in a value, which was
redundant (we could find the value from
our parent's label) and brittle (would break
on email changes).

Now the DOM's a bit slimmer and more robust.

Also note that we now deal with user_ids, not emails,
in the call stack until we hit the "edge" and convert
to emails for the server.
2020-01-27 19:30:39 +00:00
Steve Howell 548bc8a4cf stream create: Remove obsolete markup.
We removed the last code to use the data-email
markup in the last commit.  (It was actually
just needed for tests.)
2020-01-27 18:16:39 +00:00
Steve Howell ef892271dc int_dict: Fix type errors for user_groups.
This fixes some harmless type errors from the
following commit:

    6ec5a1f306

The IntDict code automatically converts strings to
integers, so this was not a user-facing problem, but
we want to have our callers do the conversions
explicitly.
2020-01-27 13:14:40 -05:00
Hashir Sarwar 91aff4eec3 invite_subscription: Add `#` to the stream names.
Written the stream names as e.g. #announce, to match
how we display them elsewhere.
2020-01-26 21:20:11 -08:00
Tim Abbott d7ba77b83b search: Simplify CSS for search_icon.
This is preparatory refactoring for replacing the top navbar UI; in
the new version, the search_icon may not be an <a> tag.
2020-01-25 23:55:48 -08:00
Rohitt Vashishtha 39420d6adb night_mode: Render the message instead of showing raw `/night` text. 2020-01-25 22:56:45 -08:00
Tim Abbott d70e799466 bots: Remove FEEDBACK_BOT implementation.
This legacy cross-realm bot hasn't been used in several years, as far
as I know.  If we wanted to re-introduce it, I'd want to implement it
as an embedded bot using those common APIs, rather than the totally
custom hacky code used for it that involves unnecessary queue workers
and similar details.

Fixes #13533.
2020-01-25 22:41:39 -08:00
orientor 030c07184a settings: Fix buggy emoji format loading spinner.
When a user clicked the current emoji format in "display settings",
we'd show an infinite loading spinner (basically as a side effect of
trying to tell the server to change the emoji format to what it
already was).

Fix this by aborting early if the emoji format is already the option
that the user clicked.

Fixes #13684.
2020-01-23 16:20:57 -08:00
Steve Howell 7d0082f5c2 topic history: Avoid duplicate server fetches.
We now only go the server if both of these
conditions are true:

    - our message data seems incomplete for
      the stream
    - we haven't already fetched history
2020-01-23 13:28:52 -08:00
Steve Howell e812dd60d6 Extract topic_data.is_complete_for_stream_id().
This function will make more sense when we start
tracking api calls that retrieve topic history.

The unit tests here are kinda duplicating what we
have in the stream_data tests.  If we move the
function out of stream_data, we can kill off the
tests there, but for now I think a bit of duplicate
testing is fine here.
2020-01-23 13:28:52 -08:00
Steve Howell 779a9cea22 topic_data: Use IntDict for stream_dict.
All the callers seem to have integer stream_ids
already, either from the message object or
some sub object.

We also use clear() inside the test-only reset()
method.
2020-01-23 13:28:52 -08:00
Steve Howell 055b13a7a8 minor: Update code comments in topic_data.
The main Dict here used to point to an array,
but that changed a few years ago.
2020-01-23 13:28:52 -08:00
Tim Abbott a3a662c7d2 message_list_view: Fix handling of links to deleted streams.
Previously, links to deleted streams would be incorrectly rendered as
stream's name).

Fixes an issue that was reported where after deleting the "general"
stream, the welcome turtle messages might appear as links to
2020-01-22 22:42:54 -08:00
Steve Howell fa82d12525 topic list: Extract topic_list_data.js.
This is mostly for tactical reasons.  It's hard to
get 100% test coverage on topic_list.js, but it
should be easy to get 100% test coverage on this
very important function.

I considered just moving this code into topic_data.js,
but it just didn't feel quite right.  I feel like
this is a pretty core piece of code that's nice
to be by itself and not be near other complicated
code that does stuff like build widgets or talk
to servers.  (And, again, it's not just the actual
code here, which is pretty small, it's the unit
tests, which are inherently verbose to exercise
all the edge cases.)
2020-01-22 14:31:33 -08:00
Steve Howell 0f368b3373 topic_list: Fix minor bug with "more topics".
There was an edge case with the old
code when you had exactly between 6 and 8
topics and all in cache, with a couple of
the topics being unread.

We would show "more topics" when you were
actually seeing all your possible topics.

To test this:
    - create 7 topics on Venice
    - as Iago, narrow to any of the Venice
      topics
    - as Aaron, send unreads to 3 or 4
      of the other topics

Eventually Iago will have all possible
topics in the sidebar.  On master we'll
show "more topics", whereas after this commit
we correctly avoid that.

It's a pretty harmless bug, since it just
leads to a useless zoom-in.

I have always felt we should zoom-in
regardless of how many topics you have,
just for consistency sake, but I also
understand the rationale behind our
current intentions.
2020-01-22 14:31:33 -08:00
Steve Howell 27bcdc567f topic_list: Extract get_list_info.
This is basically trying to confine the
rendering logic to a smaller function,
since I want to work toward a better
approach for redrawing the topic list.

Also, since the new function is now
purely data-oriented, it will be a
bit easier to test various edge cases.
2020-01-22 14:31:33 -08:00
Steve Howell 5f41d99422 topic list: Simplify active_topic code.
There's no real need to pass this through the
stack like we do.
2020-01-22 14:31:33 -08:00
Steve Howell 1eab59d1b5 topic list: Kill off "no more topics".
If you clicked for no more topics and then the server didn't find any,
we once had code that would say "No more topics" in light gray at the
bottom of the topic list.

The feature appears to have been broken by some detail in the
`self.dom` refactoring.  More importantly, it's not clear it's useful
as opposed to clutter.

Since we added the `stream.first_message_id` feature, it's now very
rare for the `more topics` option to appear when there aren't in fact
older topics that could be fetched.  In cases where there are not, the
UI is still clear about what's happening -- it shows a loading
indicator and then displays a list of topics that doesn't have
anything new.

So we're removing this feature; we can re-add it without too much
difficulty if user feedback in the future suggests it would be useful
after all.
2020-01-22 14:28:59 -08:00
Steve Howell 613b8ade20 topic list: Add is_active_topic to template.
The only place we ever set active-sub-filter is
right after we build the template, so there is
no reason to have it be a separate step.

(I made a similar fix to pm_list recently, and
this helps set the stage for doing vdom-like
stuff.)
2020-01-22 14:28:50 -08:00
Tim Abbott e459a4b7a7 topic_list: Rewrite unzoomed rendering to be readable.
The previous logic was a bit byzantine, making a lot of inferences
based on which conditionals had already been processed that made it
hard to read.  This simple function approach promises to be more
readable.
2020-01-22 14:28:50 -08:00
Tim Abbott 37b563b82f topic list: Don't include muted topics in "more topics" count.
This is for consistency with how we show unreads in muted topics at
the stream level, avoiding distracting users with the appearance of
unread messages in muted topics that they've made clear they are not
interested in.

Arguably, we should show a faded count if there are unreads on muted
topics (but none on unmuted topics), but that seems somewhat complex
to maintain, and we'd benefit from user feedback to make an effective
decision on whether it'd be an improvement.

Fixes #13676.
2020-01-22 14:28:50 -08:00
Tim Abbott 6f4f6fde79 topic list: Skip muted topics when not zoomed.
I think this probably matches users' expected behavior that muted
streams shouldn't get in their way unless the user is actively looking
for them.  If a user has a lot of muted topics with active traffic
(e.g. because topics corresponding to channels in a mirrored Slack
instance), they would previously find their 5 slots cluttered with
those muted topics even if there were unmuted topics with unread
messages.

Fixes #13677.
2020-01-22 14:28:50 -08:00
Jonathan Cobb c7433c83ff integrations: Add errbit integration.
Fixes #13685.
2020-01-16 15:33:51 -08:00
Tim Abbott e2681372f3 js: Clean up poorly named const id variables.
We have conventions for naming message_id, stream_id, etc. values that
way for readability; these entries are violations of those conventions.
2020-01-16 13:27:27 -08:00
Anders Kaseorg f13f744874 settings_profile_fields: Clean up field_id type confusion.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-01-16 13:23:47 -08:00
Anders Kaseorg 45bee2f512 js: Clean up stream_id type confusion.
Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
2020-01-16 13:23:47 -08:00