Commit Graph

135 Commits

Author SHA1 Message Date
Tim Abbott 5ee5a7e635 specators: Fix persistent recent topics loading indicator.
This unfortunately requires somewhat ugly duplicated code, but I think
it's the best option for now.

I expect we will somewhat soon work on the transition to no longer
have two duplicate fetches here, and doing so will let us remove this
secondary code path.

Fixes #21304.
2022-03-04 15:51:09 -08:00
Aman Agrawal 5ae178b39c recent_topics: Show loading indicator before fetching initial messages.
Hide the loading indicator after initial fetch for recent topics.
2022-02-25 16:29:43 -08:00
Anders Kaseorg b0ce4f1bce docs: Fix many spelling mistakes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-02-07 18:51:06 -08:00
Anders Kaseorg c6b372b471 js: Simplify indexing arrays from the end with Array#at.
https://github.com/tc39/proposal-relative-indexing-method

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-01-24 09:58:54 -08:00
Aman Agrawal d6541c4724 message_fetch: For spectators, add web-public to narrow.
Without this, server will return a 401 error.
2021-11-02 11:26:19 -07:00
Aman Agrawal 9bd2701f5b message_fetch: Don't re-fetch recent msgs for spectator.
Since a spectator cannot have unread counts, we always
fetch the most recent messages. Hence, there is no need to
separately fetch this in this case.
2021-09-06 09:00:16 -07:00
Aman Agrawal 88454307cd recent_topics: Split into three modules.
We split recent_topics module into recent_topics_(ui + data + util).

This allows us to reduce cyclical dependencies which were
created due to large list of imports in recent topics. Also, this
refactor on its own makes sense.
2021-06-10 15:53:05 -07:00
Anders Kaseorg 7fd1e33d1b eslint: Fix unicorn/require-number-to-fixed-digits-argument.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-06-08 10:15:52 -07:00
Anders Kaseorg 544bbd5398 docs: Fix capitalization mistakes.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-05-10 09:57:26 -07:00
Anders Kaseorg 178736c8eb docs: Fix spelling errors caught by codespell.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-04-26 09:31:08 -07:00
Anders Kaseorg 6f764ce4b3 message_list: Downgrade message_list.all to MessageListData.
This data structure has never been one that we actually render into
the DOM; instead, its role is to support clicking into view that
contain muted streams and topics quickly.

This downgrade makes that situation much more explicit, and is also
useful refactoring to help simpify the upcoming changes in #16746.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-30 08:33:47 -07:00
Anders Kaseorg d43ac7357a js: Move current_msg_list, home_msg_list to ES6 module message_lists.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-29 18:23:47 -07:00
Steve Howell 45d806d9aa refactor: Extract message_helper.process_new_message.
We move the message_store.add_message_metadata function
(and all its dependencies) into a new module called
message_helper and rename the function to process_new_message.
(It does a bit more than adding message metadata, such
as updating our message store.)

We also have a "protected" interface now in message_store,
so that message_helper can access the message store:

    update_message_cache
    get_cached_message

Because update_message_cache is identical to
the former create_mock_message, we just renamed it
in the tests.

Most callers should use these functions:

    message_helper.process_new_message (setting)
    message_store.get (getting)

It's slightly annoying that the setter interface
is in a different module than the getter interface,
but that's how you break a bunch of dependencies.

We also extract the tiny message_user_ids class:

    user_ids()
    add_user_ids()

All the code moves here are pretty trivial, and
the code that was moved maintains 100% line
coverage.

The module name `message_helper` is not ideal, but it's a single
function and it'll save time to just do the topology change now and
leave thinking through the right name to later.
2021-03-29 14:53:57 -07:00
Steve Howell 98372cd244 refactor: Make home_view_loaded into a callback.
This reduces our extraneous deps from 72 to 71.
2021-03-28 15:55:55 -07:00
Steve Howell c67f82b073 refactor: Extract narrow_banner module.
This is a mostly verbatim extraction.

I re-phrased one line of code to work around a lint
false alarm. (Look for `preamble` in the diff.)

There are about 8 lines missing coverage here, so
the new module might be a good candidate to get
100% line coverage on.

Before this change, you would need to remove 74
edges from our dependency graph to make it
acyclic. Now it's 72.
2021-03-28 15:55:55 -07:00
Anders Kaseorg 38ffd47b90 js: Convert static/js/page_params.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-26 10:17:56 -07:00
Anders Kaseorg ea9ca6b7d0 js: Use jQuery as a module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-12 10:08:25 -08:00
Anders Kaseorg e74598da17 js: Convert static/js/narrow.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 7a67c06581 js: Convert static/js/message_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 3e8ddc229b js: Convert static/js/stream_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-03-02 17:06:35 -08:00
Anders Kaseorg 1a8422b152 js: Convert static/js/recent_topics.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 19bb5fa7ad js: Convert static/js/server_events.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 21c6a3d87a js: Convert static/js/message_fetch.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 7a45ed46af js: Convert static/js/message_util.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 7145cb4a0d js: Convert static/js/message_store.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 5b2b2924be js: Convert static/js/message_scroll.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 26710a4370 js: Convert static/js/ui_report.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 245d6c3a3e js: Convert static/js/stream_data.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg cfacf68fb8 js: Convert static/js/filter.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 850c3c65e7 js: Convert static/js/pm_list.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08:00
Anders Kaseorg 09920af211 js: Convert static/js/channel.js to ES6 module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-02-28 14:23:00 -08: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
Anders Kaseorg 552f4e3d22 eslint: Fix unicorn/no-array-for-each.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2021-01-25 14:53:19 -08:00
ryanreh99 7562886cef ui: Hide loading indicators for non-existant narrows.
We were still displaying the loading spinner
even after displaying the error text, which
was confusing as we do not try to fetch again.
This fixes it.
2020-11-29 18:07:56 -08:00
Tim Abbott d3ebfce4ae message_fetch: Refactor logic for constructing data.narrow.
This refactoring should have no functional effect for any call points,
but makes the function behave more naturally.  The comments explain
the situation, but specifically:

* There's the page_params.narrow hack that affects both narrows and
  home_msg_list.

* There's the shared data for home_msg_list and all_msg_list that
  requires we modify the query from home_msg_list.data.public_operators().

And otherwise the logic should just use the operators associated with
the message_list.data object (allowing us to remove the force_fetch
hack added in the last commit).

Hopefully in some future refactoring, we'll be able to migrate those
hacks to live in the Filter object construction and eliminate this
block of conditionals entirely.
2020-11-20 11:50:01 -08:00
Ryan Rehman ec3df8cb4f message fetch: Pass narrow param for recent topics message list.
In commit ebea17b9a6,
we added an extra fetch to get accurate data for the top
items in recent topics table.
But the `narrow` parameter wasn't passed to the endpoint,
this resulted in fetching the user's overall message
history including the muted streams/topics which aren't
required by the recent topics table.

`operators` can be replaced as we set the same value for
the `narrow_state` module and the narrowed message list's
filter, when activating the narrow.
2020-11-20 11:47:46 -08:00
Tim Abbott ebea17b9a6 message_fetch: Add an extra fetch for Recent Topics.
The comment explains the problem statement in some detail, but
basically this algorithm ensures that the top items in "Recent Topics"
on page load are always the very most recent topics the user has
received messages in (well, ignoring muted topics in this iteration).
2020-11-05 10:38:45 -08:00
Anders Kaseorg b178fc6069 eslint: Fix unicorn/prefer-set-has.
https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/prefer-set-has.md

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-10-07 16:00:33 -07:00
Anders Kaseorg fe66aef0ad blueslip: Replace fatal with throw new Error(…).
This makes it clear to humans and ESLint that execution will not
continue.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-09-25 15:17:36 -07:00
Priyank Patel b7998d3160 js: Purge people module from window. 2020-09-01 19:55:58 -07:00
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
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
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 883e2fd325 js: Remove inner spacing from object literals.
We’re configuring Prettier with bracketSpacing: false.  Generated by
ESLint.

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 a79322bc94 eslint: Enable prefer-arrow-callback.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-03 16:55:50 -07:00
Anders Kaseorg b0253c5a2e eslint: Enable arrow-parens.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-07-03 16:53:39 -07:00
Ryan Rehman fae365f8c7 message fetch: Fix anchor parameter before fetching messages.
If the `load_messages_for_narrow` function tried to fetch messages with
a floating point anchor (locally echoed message id) we get a 400 error.

The logic to remove the rounding of the anchor parameter was done in
commit bf2f36e6b4, as it would always be
an integer in all incoming code paths.

However, since then we have updated the GET /messages API, to also allow
strings as the anchor parameter and this value's parsing is done in the
backend.

Fixes #15497.
2020-06-23 15:46:04 -07:00
Tim Abbott 3dac8d7d97 message_fetch: Rename constants for clarity.
The "pointer" is no longer a concept; what we mean to refer to here is
the anchor.
2020-06-18 12:55:59 -07:00
Tim Abbott f28b38bd8c message_fetch: Use first unread anchor for home view.
This fixes one of our oldest important user experience issues, namely
that if you never visit the home view, the Zulip webapp would often
load "deep in the past" because the pointer had not advanced.

Fixes #1529.
2020-06-17 18:08:48 -07:00