Commit Graph

39 Commits

Author SHA1 Message Date
Evy Kassirer
3c4fe73470 message: Differentiate between new local messages and server messages. 2025-10-01 16:38:55 -07:00
Lauryn Menard
1c7e4a5e09 compose-closed: Fix updating buttons when not in DM narrow.
When processing a server event or an empty message fetch,
we were incorrectly updating the closed new conversation
button attribute, "data-conversation-type" to be "direct"
without checking to see if the current narrow filter was
actually a direct message view.

Adds a helper function that checks the current filter for
contains_only_private_messages and then calls
compose_closed_ui.update_buttons_for_private when true.

That's the same check that's used in
message_view.handle_post_view_change when
compose_closed_ui.update_buttons_for_private is called,
so we're consistently using the same check when updating
the closed compose box buttons for this state.
2025-09-23 12:32:40 -07:00
Anders Kaseorg
a29ed94e5b web: Switch to Zod mini API.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2025-07-21 16:40:17 -07:00
Jitendra Kumar
4696c8eb67 message_list: Update trailing bookend on empty channel or topic.
Show `You are not subscribed to  #xyz. Subscribe` bookend
on channel or topic which are not subscribed and have no messages.

Fixes: #33209
2025-03-25 16:04:55 -07:00
Aman Agrawal
37d91d9759 message_fetch: Fix load_messages called unexpectedly.
Since we set a new timeout on every connection error, we can
unconditionally clear the timeout when load_messages is called.

This fixes the error when `load_messages` is called irrespective
of `delay_secs` timer.
2025-03-18 11:26:10 -07:00
Kislay Verma
a3a0419e9c popup_banners: Improve connection error banner.
This commit makes the following changes:
- Prevents the codepath in load_messages in message_fetch and
  get_events in server_events from interfering with each other.
- The banner label now displays the time interval after which the
  connection will be retried.
- The loading indicator now shows on the banner when the retry is in
  progress via the JS logic.

Co-authored-by: Sayam Samal <sayam@zulip.com>

Fixes #33924.
2025-03-17 18:25:32 -07:00
Aman Agrawal
bf508ce638 message_view: Notify user when the local first unread was incorrect.
Fixes #33570

When navigating to a narrow based on locally available unread
data with `old_unreads_missing`, we verify the calculated
first unread message id with server and if there is an unread message
prior to the one we calculated locally, we convert the current
narrow into a `near` narrow and show a banner with a button to
allow user to navigate to the correct first unread message.
2025-03-13 17:41:47 -07:00
Sayam Samal
3275fcc96e popup_banners: Redesign connection banner to use new banner component.
This commit serves as the base commit for redesigning the alert banners
by migrating them to use the new banner component. We use a new name
to refer to these banners — "Popup banners", which is more descriptive
about their behavior.

The Popup banners are appended to the container in a stacking order,
i.e., the most recent popup banner appears on the top and the oldest one
is sent to the bottom of the stack. These banners also inherit the
animations from the alert banners for visual appeal.

This commit also fixes the bug where clicking on the "Try now" button
in the popup banner resulting from an error in the `/json/messages`
endpoint resulted in call to restart_get_events in server_events.js
instead of load_messages in message_fetch.ts.

Fixes #31282.
2025-03-10 11:21:11 -07:00
Lauryn Menard
cb8e67a0e6 narrow-banner: Pass filter for showing/picking an empty narrow banner.
We expect to have a message list and therefore a filter when we show
or pick an empty narrow banner.
2025-03-04 15:35:18 -08:00
Lauryn Menard
078ce89380 util: Extract helper function for backoff of retries on error response.
Extracts message_fetch and get_events algorithms for calculating the
exponential backoff into a shared helper function.

These match the algorithm that were designed for the Python API, except
that we use a ratio of 2 rather than sqrt(2) in the message_fetch code
path.
2025-01-29 15:00:23 -08:00
Aman Agrawal
548afc2f1a topic_summary: Add button to generate narrow summary.
This remains only enabled in the development environment.
2025-01-28 13:13:20 -08:00
Aman Agrawal
673281aae8 message_fetch: Extract function to modify narrow before server query. 2025-01-23 16:29:42 -08:00
Prakhar Pratyush
fd67e31163 web: Add parameters to API requests for empty topic name support.
This commit adds `allow_empty_name: true` to the following
endpoints to receive empty strings as topic name when such
topics are available:
* `GET /messages`
* `GET /messages/{message_id}`
* `GET /messages/{message_id}/history`

Also, it adds `empty_topic_name` client capability for spectators.

These changes are part of the broader effort to enable
support for empty string as a topic name.
2025-01-10 14:32:55 -08:00
Aman Agrawal
864a2a067e recent_view: Fetch significant message history per Load more click.
Increase required messages significantly before stopping the backfill
every time `Load more` is clicked.
2025-01-08 10:56:14 -08:00
Aman Agrawal
c2df278f6d recent_view: Fix Load more not working after fetching 50k messages.
We do another fetch for `recent_view_fetch_more_batch_size` after
reaching 50k limit each time `Load more` is pressed.
2025-01-07 09:46:58 -08:00
Aman Agrawal
c5feccaa34 message_list: Rename variable for caller clarity. 2025-01-02 17:27:02 -08:00
Aman Agrawal
525ae3aaff message_list: Fix message list missing messages.
Since we allow calling `add_messages` without checking fetch status,
it can lead to non-contiguous message history due to latest message
being added to a message list without previous messages being
fetched.

To fix it, we only allow adding new messages via message_fetch
which properly sets `anchor` to the last message in the list
before fetching and adding messages to the list.
2024-12-18 10:21:48 -08:00
Aman Agrawal
9e519f8c18 message_fetch: Fix incorrectly set fetch status.
We update the fetch status before reaching here, so it was
incorrect to return before adding messages to the message
list data since it is always cached.
2024-12-18 10:21:48 -08:00
Aman Agrawal
a95f419650 message_fetch: Improve check for if message list is cached.
Combined feed is no longer cached by default, so this is the
correct check for if the message list is cached or not.
2024-12-18 10:21:48 -08:00
Aman Agrawal
0af738269a stream_list: Ignore left sidebar scroll until initial fetch is complete.
Since the initial fetch has a lot of messages, it can add many topics
to the left sidebar which can move the selected topic out of the view.

Note that `has_scrolled` is triggered even for the scrolls not triggered
by user since it is not easy to differentiate between the two events.
So, it is okay to ignore it initially.
2024-12-12 18:40:19 -08:00
Anders Kaseorg
77f97762c6 eslint: Fix unicorn/explicit-length-check. (#32666)
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-12-11 09:19:46 -08:00
Aman Agrawal
a6aef4f41b message_fetch: Check for empty narrow to show empty narrow banner. 2024-12-04 16:16:25 -08:00
Aman Agrawal
40eda337f9 message_fetch: Populate rendered message lists with all_messages_data.
This will help us provide more messages in the current narrow for the
user after a reload without any extra server queries.
2024-12-04 16:16:25 -08:00
Aman Agrawal
107559b1bb message_fetch: Fetch again if the view is not scrollable.
If the initial fetch for the narrow didn't return enough data for
the view to becomes scrollable, we should try to populate the narrow
with more messages.
2024-12-04 16:16:25 -08:00
Aman Agrawal
dc63415c9d message_fetch: Allow fetching more messages for combined feed.
Since `all_messages_data` is no longer the data for combined feed,
we need to treat combined feed like any other view and continue
fetching messages if required.
2024-12-04 16:16:25 -08:00
Aman Agrawal
5ee62e599b message_fetch: Extract function to standardize API parameters.
There some common checks we need to perform before requesting
messages from the server. We extract it to be used elsewhere.
2024-12-02 16:41:36 -08:00
Aman Agrawal
1954855b6a message_fetch: Remove no longer needed check for home filter.
`Filter.public_terms` will return the same result even if the
narrow is combined feed. Since we are no longer passing
empty narrow parameters for combined feed, this condition is
not required.
2024-12-02 16:41:36 -08:00
Aman Agrawal
09c9db7b18 message_fetch: Remove inaccurate comment.
This comment became inaccurate as we made combined feed to no longer
be a special view.
2024-12-02 16:41:36 -08:00
Aman Agrawal
3fef305557 message_fetch: Extract part of post message fetch process.
This will be useful to separately call when restoring msg list
from cached msg list data.
2024-12-02 16:41:36 -08:00
Anders Kaseorg
ec3177c834 web: Add explicit extensions to imports.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2024-11-13 09:18:56 -08:00
Lauryn Menard
93c172ee3f message-fetch: Add spectator term when building narrow parameter.
Again, since the spectator term is added to the narrow parameter
for all views, then we consolidate that logic when building the
initial narrow data.
2024-10-14 15:11:41 -07:00
Lauryn Menard
7289d43f74 message_fetch: Simplify building narrow data.
If page_params.narrow is defined, then it is added to the narrow
parameter (whether it is the home view or not), so here we
consolidate that logic.
2024-10-14 15:11:41 -07:00
Lauryn Menard
09bce62d98 messsage-fetch: Convert channel operator's operand to integer ID.
The operand for the canoncial "channel" operator can be an ID, but
it must be an integer and not a string, so we take care of that
directly in handle_operators_supporting_id_based_api.
2024-10-14 15:11:41 -07:00
Lauryn Menard
3405e95b6b message-fetch: Use canonical operator for ID based API updates.
Updates handle_operators_supporting_id_based_api to use the
canonical operator when updating the narrow parameter to use
object IDs.
2024-10-14 15:11:41 -07:00
Lauryn Menard
62c2f35995 message-fetch: Refactor handle_operators_supporting_id_based_api.
Instead of updating the object with all of the parameters for the
message fetch, we only update the narrow parameter.
2024-10-14 15:11:41 -07:00
evykassirer
b2e1c5aec4 message_fetch: Don't allow undefined narrow term operands. 2024-09-24 14:34:07 -07:00
evykassirer
deb5d90941 message_list: Convert module to typescript. 2024-09-19 15:31:16 -07:00
evykassirer
dba1af84e0 filter: Use stream id instead of stream name. 2024-09-18 13:08:14 -07:00
afeefuddin
f013eb1037 message_fetch: Convert module to TypeScript. 2024-08-23 13:34:13 -07:00