Commit Graph

11016 Commits

Author SHA1 Message Date
Anders Kaseorg 5182505302 dropdown_list_widget: Add missing export.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 07:35:11 -08:00
Anders Kaseorg 4d6a017320 people: Modernize CommonJS reference in comment.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-10 09:45:10 -05:00
Abhijeet Prasad Bodas 9cb41c2976 refactor: Extract `excludes_muted_topics` logic.
This commit makes it so that MessageListData
methods always attempt to filter muted messages.
We later, in a new function
(`messages_filtered_for_topic_mutes`)
check if `excludes_muted_topics` is true or not,
and skip the filtering work if it isn't.
This new function consistently returns a new list.

This refactor will later allow us to write clean
and concise code as part of mute users.

This commit also refactors the muting tests
for MessageListData, which were earlier
spread across two `run_test` functions.
These tests should remain organized,
since similar tests will be added as part of
user mutes in future commits.
2021-02-10 07:53:05 -05:00
Abhijeet Prasad Bodas 9ae44c769c refactor: Rename MessageList.muting_enabled.
Previously, the `muting_enabled` property of
MessageListData class was used to indicate whether
some messages in the message list need to be
filtered due to topic muting, depending on the
narrow. For example, we exclude messages belonging
to muted topics from stream narrows, but not from
search narrows.

The name `muting_enabled` is a bit confusing, and hence is
changed to `excludes_muted_topics`.
It is also important that the name be specific, since
a similar new property will be added for user mutes
in future commits.
2021-02-10 07:53:05 -05:00
Suyash Vardhan Mathur c9c40d4fd2 api docs: Cleaned up CSS for parameter classes.
Deduplicated CSS classes of data types of response and
request parameters in API Documentation to use a single
class.
2021-02-09 10:31:36 -08:00
Chris Taylor e341a81987 Tooltip: edited tooltip string to add consistency in static/js/ui.js. 2021-02-09 10:44:21 -05:00
Anders Kaseorg 9896782fd1 dependencies: Remove XDate.
It’s even more unmaintained than Moment and doesn’t add any
functionality we don’t already have.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-07 06:41:33 -05:00
Anders Kaseorg 952a8aa5fd drafts: Fix racy computation that gets current time twice.
The result could have been off by a month if the two calls to new
Date() straddled a month boundary.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-07 06:35:54 -05:00
Anders Kaseorg 42a9e473ae components: Allow passing labels as HTML (but explicitly).
Fixes the sorting button labels in stream settings, which were
regressed by commit f8fbae4d8e (because
the HTML was not marked as being HTML).

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-05 20:12:57 -08:00
Aman Agrawal 6972b31721 subscription_members: Make the help text more clear. 2021-02-06 08:51:36 +05:30
Aman Agrawal 93889d9690 notificaiton_sounds: Add some atonal sounds created by @stwime.
Removed underscore from names.
2021-02-05 12:28:20 -08:00
Aman Agrawal 8baade439d notification_sounds: Add sounds created by @stwime.
These are all good notification sounds that may fit taste of
different users.
2021-02-05 12:28:20 -08:00
Abhijeet Prasad Bodas fd2bf0b31b refactor: Rename frontend muting stuff to include 'topic'.
This is a prep commit, which renames some variables
and functions involved in topic muting to include
the word "topic" in them.

This is done to have clarity when similar code
will be added as a part of the mute-user in
future commits.
2021-02-05 11:17:46 -08:00
Abhijeet Prasad Bodas 5eec4b23ac minor: Explicitly handle undefined date while muting a topic.
If we don't pass `date_muted`, we shouldn't calculate
date_muted * 1000. This code used to work because of
how javascript treats `undefined`.

This commit deals with the `date_muted=undefined` case
in a cleaner manner.
2021-02-05 11:17:46 -08:00
Abhijeet Prasad Bodas dbb69f76fa settings: Fix message not shown in empty muted topics list.
This commit fixes a small bug in the
settings/muted-topics pane.
When there are zero muted topics, the
"You have not muted any topics yet." message
was not shown.

This is fixed by adding the `required-text`
class to the table body.
The bug was introduced in 3bc818b9f7.
2021-02-05 11:17:46 -08:00
aryanshridhar f92f99d92d dependencies: Replace moment.js with date-fns.
Replaced methods/functions of moment.js with date-fns library.
The motive was to replace it with a smaller frontend timezone library.

Date-fns ~ 11.51 kb
moment.js ~ 217.87 kb

Some of the format strings change because date-fns encodes them
differently from how moment did.

Fixes #16373.
2021-02-05 11:04:32 -08:00
Suyash Vardhan Mathur 26a81ab3aa api docs: Display data type of responses in API Documentation.
Previously, the data type of responses wasn't displayed in the API
Documentation, even though that OpenAPI data is carefully validated
against the implementation. Here we add a recursive function to
render the data types visibly in API Documentation.
Fixes part of #15967.
2021-02-05 10:41:42 -08:00
Anders Kaseorg f8d11c6479 compose: Generate properly escaped HTML.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-05 09:26:47 -08:00
Anders Kaseorg 154fc03fa5 composebox_typeahed: Generate properly escaped HTML.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-05 09:26:47 -08:00
Anders Kaseorg dc0972b775 loading: Generate properly escaped HTML.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-05 09:26:47 -08:00
Anders Kaseorg 56d0d30387 hotspots: Generate properly escaped HTML.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-05 09:26:47 -08:00
Anders Kaseorg f8fbae4d8e components: Generate properly escaped HTML.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-05 09:26:47 -08:00
Anders Kaseorg 64b78ad992 styles: Use range context queries to eliminate *_max variables.
On a high-DPI display or with a non-default zoom level, the browser
viewport may have a width strictly between md_max = 767px and md_min =
768px.  Use only the *_min bounds for consistency.

This requires queries with strict inequalities to express upper
bounds (width < md_min).  Fortunately, that functionality is provided
by range context queries.  Unfortunately, those are not supported in
all browsers.  Fortunately, we can compile them away using
postcss-media-minmax.  Unfortunately, postcss-media-minmax currently
subtracts 1px for strict inequalities anyway to work around a Safari
rounding bug.  Fortunately, 0.02px should be sufficient for that, so I
submitted a PR:

https://github.com/postcss/postcss-media-minmax/pull/28

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-05 09:23:59 -08:00
Anders Kaseorg d679aa015d scroll_bar: Flip max-width queries for min-width.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-05 09:23:59 -08:00
Anders Kaseorg aa650a4c88 js: Escape strings interpolated into CSS selectors with CSS.escape.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-04 11:00:06 -08:00
Anders Kaseorg 08fe6e4a8f blueslip: Pass through the return value in measure_time.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-04 09:11:04 -05:00
Steve Howell 17ea215f18 minor: Remove peer_data.clear(). 2021-02-03 15:23:17 -08:00
Steve Howell 58855e8224 refactor: Remove maybe_clear_subscribers().
The maybe_clear_subscribers() function was an artifact of
when we used to attach subscribers to the "sub" records in
stream_data.js.  I think it was basically a refactoring
shim, and due to some other recent cleanup, it was only
used in test code.

We also change how we validate stream ids.

Going forward, peer_data just looks up stream_ids with the
normal stream_data API when it's trying to warn about
rogue stream_ids coming in.  As I alluded to in an earlier
commit, some of the warning code here might be overly
defensive, but at least it's pretty self-contained.
2021-02-03 15:23:17 -08:00
Steve Howell e44e48ef20 minor: Add get_user_set call that I missed earlier.
In my recent commit to introduce get_user_set() I
inadvertently skipped one place to call it.

I also remove a return statement that was made
unnecessary by the new get_user_set() helper.
2021-02-03 15:23:17 -08:00
Steve Howell 016038dcd1 blueslip: Add measure_time wrapper.
Now when we want to measure how long a block
of code takes to execute, we just wrap it with
`blueslip.measure_time`, instead of the awkward
idiom from my original commit of getting a callback
function.

My rationale for the original scheme was that I
wanted to minimize diffs and avoid changing
`const` to `let` in a few cases, but I believe
now that the function wrapper is nicer.

In a few cases I just removed the blueslip timing
code, since I was able to confirm on czo that
the times were pretty minimal.
2021-02-03 15:23:17 -08:00
Ganesh Pawar f70629ea6c composebox: Add typeahead for /todo. 2021-01-30 09:01:13 -08:00
Ganesh Pawar 632abd45eb ui_report: Migrate ui_report.message to ui_report.client_error. 2021-01-30 07:48:44 -08:00
Ganesh Pawar 5802bbfb98 ui_report: Add ui_report.client_error. 2021-01-30 07:48:44 -08:00
Steve Howell e243af531b refactor: Extract get_user_set in peer_data.
We now use the same code in all places to
get the bucket of user_ids that correspond
to a stream, and we consistently treat
a stream as having zero subscribers, not
an undefined number of subscribers, in
the hypothetical case of us asking about
a stream that we're not tracking.

The behavior for untracked streams has
always been problematic, since if a
stream is untracked, all bets are off.

So now if we don't "track" the stream,
the subscriber count is zero.  None of
our callers distinguish between undefined
and zero.

And we just consider the stream to be subscribed
by a user when add_subscriber is called,
even if we haven't been told by stream_data
to track the stream.  (We also stop
returning true/false from add_subscriber,
since only test code was looking at it.)

We protect against the most likely source
of internal-to-the-frontend bugs by adding
the assert_number() call.

We generally have to assume that the server
is sending us sensible data at page load
time, or all bets are off.

And we have good protections in place
for unknown ids in our dispatch code
for peer_add/peer_remove events.
2021-01-29 15:21:07 -08:00
Steve Howell 52281462e2 zephyr: Close exemption for stream-link warnings.
For the rare case where you're doing a link to a private
stream from a larger private stream that is a superset of
the former, we have bypassed warnings that you are linking
to a private stream.

I'm not sure we need this exemption for any situation
(just let the user bypass the warning), but we definitely
don't want false positives for the exemption.

For now I am closing down this loophole specifically for
Zephyr users.

Zephyr users are special in that we might not get
subscriber info on certain streams.

The current behavior for this edge case is a little
unclear.  The current implementation of
peer_data.is_subscriber_subset returns false if both
streams are untracked, but most streams are tracked if we
have a sub for them and just get treated as having an
empty set of subscribers.  And an empty set is a subset of
itself.  Upcoming changes to our server data are gonna
make this edge case even more annoying to maintain.
2021-01-29 15:21:07 -08:00
Steve Howell 5a27ed6a72 refactor: Change where we initialize scrolling code.
This is a more sensible place to initialize the
the scrolling handler, plus it breaks an annoying
indirect dependency on jQuery for the unit tests.
2021-01-29 15:21:07 -08:00
Steve Howell 6c4b1183f2 node tests: Move peer_data tests to new peer_data.js. 2021-01-29 15:21:07 -08:00
Steve Howell 2edfdb4ff8 refactor: Extract bulk functions to add/remove peers.
We also streamline some of the error handling code
by doing everything up front.  This will prevent
scenarios where a single bad stream_id/user_id causes a
bunch of the same warnings in an inner loop.
2021-01-29 15:21:07 -08:00
Steve Howell 805a2b6670 refactor: Remove stream_data.update_subscribers_count.
This removes a bit of complexity.  If a piece of
settings code needs to render a stream with
subscribers, it just asks for it.

We no longer have the brittle, action-at-a-distance
mechanism of mutating the subscriber count on to
the stream_data version of a sub.

Stream subs are pretty small, so making copies of
them is cheap, and the blueslip timings from the
previous commit can help confirm that.

There is some discussion of putting `subscriber_count`
on the Stream model, which may eventually get us
away from tracking it in `peer_data.js`, but we will
cross that bridge when we get there.  See
https://github.com/zulip/zulip/issues/17101 for
more details.
2021-01-29 15:21:07 -08:00
Steve Howell 5bd68b5180 minor: Get blueslip times for stream settings. 2021-01-29 15:21:07 -08:00
Steve Howell dc9b4de05f refactor: Call peer_data.get_subscriber_count().
We are trying to move away from having the
subscriber count on the sub.

This commit handles the easy one-liners
in the JS code.
2021-01-29 15:21:07 -08:00
Steve Howell 5babe54310 typeahead: Use stream_weekly_traffic for tiebreaker.
The weekly stream traffic is a better tiebreaker
for stream typeaheads than subscriber count, as
it's more directly a measure of a stream's current
relevance.

Normally stream traffic and subscriber counts are
closely correlated, but a good example for me is
the #twitter feed on czo, which only has 80 subscribers,
but which gets more traffic than our #integrations
stream (with 16k subscribers).  I would rather
see #twitter win the tiebreaker (if it even got
to the tiebreaker).

The main motivation behind this fix, though, is
to break our dependency on peer_data, which has
some upcoming changes that will introduce some
performance tradeoffs, and I want one less place
to audit.

Also, it will be easier long term to share this
code with mobile if we don't require mobile
to pull in our peer_data dependency.  (The webapp
has different forces than mobile that dicate
our data structures.)
2021-01-29 15:21:07 -08:00
Nikhil Maske aadd42f9e8 design: Adjust the visibility of the spinner icon.
The spinner icon is not visible until the user clicks on topic_edit_save,
so the space alloted to spinner-icon looks empty for rest of the time.
To improve the design, the spinner icon is only shown when the user
clicks on topic_edit_save.
2021-01-29 14:55:06 -08:00
Rohitt Vashishtha 75a0fa5b91 Rename list_render -> ListWidget.
Similar to DropdownListWidget, list_render is actually a widget. The
changed case more accurately represents how its supposed to be used
as a Class.
2021-01-29 09:36:35 -08:00
Anders Kaseorg 1a148f5d9a scroll_bar: Fix incorrectly converted breakpoint.
Commit e941ee4a15 (#16680) incorrectly
converted this from 775px to xl-max = 1199px instead of md-max =
767px, causing misplacement of the FRB for browser widths between
these values.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-01-27 10:32:45 -08:00
Aman Agrawal 8729965548 last_seen_status_from_date: Fix incorrect last seen value.
We use day_old calculated based on day instead of hours to
render last seen values. This fixes us incorrectly quoting
anything 24 - 48 hours ago as Yesterday and
incorrectly quoting `time` that are Yesterday
but < 24 hours ago in 'x hours ago' format.
2021-01-27 09:58:22 -08:00
Aman Agrawal de4aeacbb1 left-sidebar: Only add expanded class to it if it is a popover.
We were adding `expanded` class to left-sidebar when searching
for streams even if the left-sidebar was not in the popover state.
This cased confusion with popovers.any_active returning true,
when actually it is not.
2021-01-27 09:58:22 -08:00
Aman Agrawal 459e1fc218 sent_messages: Pass correct reference of this in setTimeout.
We explicitly bind `this` to MessageState class which otherwise
was defaulting to `window`.

This resulted in variables like `this.received` and `this.local_id`
being incorrectly interpreted by called function
as `window.(received | local_id)` which are `undefined`.
Hence, frontend thinks that the message was never received.

It was noticed since this was the common log message when
a double message send bug was observed. This change in no
was indicates fixing of the double send bug, but is hopefully
one step forward in that direction.
2021-01-27 09:52:42 -08:00
Anders Kaseorg 8d44cd78ec eslint: Fix unicorn/no-this-assignment.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-01-25 14:53:19 -08:00
Anders Kaseorg a679ee12f3 eslint: Fix unicorn/prefer-regexp-test.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-01-25 14:53:19 -08:00