Commit Graph

716 Commits

Author SHA1 Message Date
Joelute 245c855376 user_setting: Update wording for "Mark messages as read on scroll" setting.
Previously, the user setting "Mark messages as read on scroll" sounded
quite awkward and possibly confusing at times. We should update the text
to something more clear and concise. This change will change "Mark messages
as read on scroll" to "Automatically mark messages as read".

The help center article is also fixed to name which setting is being
adjusted.
2023-05-08 15:49:47 -07:00
Tim Abbott 9e5c1eff4b scheduled messages: Fix incorrect mapping of 4PM to 16:00 hours. 2023-05-08 15:10:52 -07:00
Karl Stolley 466422800a scheduled_messages: Allow Today scheduling thru :54 past the hour.
This PR allows users to schedule Today messages from the modal opts
thru 8:54am (8:54) for sending at 9:00am, and thru 3:54pm (15:54) for
sending at 4:00pm. (That's including up to :59 seconds, of course, on
:54 after. So, XX:54:59.)

We also correct tests that were verifying incorrect logic of expecting
a 2PM cutoff, when we intended 4PM.

Fixes first part of #25451.
2023-05-08 15:10:52 -07:00
Karl Stolley a318e7cbf4 scheduled_messages: Don't offer to reschedule in the past.
This introduces a function that checks for both the existence and the
expiration of the `selected_send_later_timestamp`.

The logic it supports prevents users from scheduling a message to send
in the past or less than five minutes into the future at the level of
the UI (specifically the popover on the \vdots component of the Send
button). That can happen if a user attempts to edit a previously
scheduled message.

Fixes #25439.
2023-05-08 15:10:52 -07:00
Joelute 90bf36887a unread_banner: Update link on unread banners to direct users to setting.
Previously, the link on the unread banners redirected users to the help
center, instead we should change it so that it opens the display settings
up.
2023-05-08 15:00:20 -07:00
Joelute 9cabdf2033 dark_theme: Add dark themed colors to notice/info banners.
Previously, infomational banners didn't have any dark theme stylings which
resulted in a messy and terrible contrast with the dark themed app. These
changes adds those missing styles and uses the same stylings and colors
as the compose banners. Thus, making a definite improvement then before.
2023-05-08 15:00:20 -07:00
Joelute 17252cc526 popover: Allow message actions menu to support larger max-width.
Previously, the option texts were split into 2 lines due to the lack of
space in the message menu. We want to fix this by increasing the max-width
of the menu so it can support the entire text in 1 line while also providing
additional space for longer text.

Since, 320px is the maximum supported supported width for mobile, we will
allow the max-width value to flex from 320px to 350px depending on the
window_width
2023-05-08 11:28:45 -07:00
Tim Abbott a97c4708e8 message_list: Fix incorrect fetch_status check.
Fixes a typo introduced in 2084a91af9.
2023-05-08 10:48:54 -07:00
Aman Agrawal c756e950c7 tippyjs: Hide recipient bar tooltips on msg_list rerender.
I noticed a floating "Go to direct message ..." on chat.zulip.org,
and then found out that these don't use message_list_tooltip.
2023-05-08 09:47:38 -07:00
Karl Stolley 8447aa747c scheduled_messages: Explicitly pass date to compute_send_times(). 2023-05-07 11:57:20 -07:00
Karl Stolley 3e2422c8fe scheduled_messages: Prepare proper sending timestamps in Node test.
This corrects the scheduled message test to ensure that each relative
day (today, tomorrow) has the correct GMT timestamp for 9am and 4pm.
2023-05-07 11:57:20 -07:00
Hardik Dharmani b9611489ca node_tests: Extend unread.test.js to catch private message mentions bug.
In the "mentions" test, an additional unread message with the type
"private" and directly mentioning me has been added. This test case
checks for the scenario when the stream_id is null during the
reverse_lookup, which would have caused the test to fail before the
bug fix was implemented which now passes after the fix is applied.
2023-05-05 16:27:03 -07:00
Akarsh Jain b063779800 settings: Hide "Add a new emoji" button for unauthorized users.
This commit fixes the issue where the "Add a new emoji" button
was being displayed for users who did not have the necessary
permissions to add emojis. With this fix, the button will no
longer appear for unauthorized users, aligning with the
current behavior for bots and user groups.

Fixes #24918.
2023-05-05 16:22:24 -07:00
Tim Abbott 4566695b9d message_events: Clarify moved_message variable name. 2023-05-05 16:18:36 -07:00
Tim Abbott f9f68de0ac messages_events: Rename messages_to_rerender. 2023-05-05 16:18:36 -07:00
Sahil Batra 3992db5a19 message_edit: Editing topic from message header should move all messages.
Editing topic from message header should now move all the messages in
the topic and not just the messages below the recipient bar.
2023-05-05 16:18:36 -07:00
Sahil Batra 146f78a83d message_fetch: Return "first_unread" as backfill anchor for empty list.
We now return "first_unread" as anchor from get_backfill_anchor in
case when the message list is empty instead of throwing an error.
Doing this, would just result in fetching the messages normally like
it happens when a user narrows to a stream by clicking on it from
sidebar.

This also helps us handling the case, when all messages in the
current stream narrow are removed due to moving them, by fetching
the other messages from server for that stream narrow.
2023-05-05 16:18:36 -07:00
Sahil Batra 168680af23 message_events: Update code to handle messages not available locally.
Previously, if the client recieved an "update_messages" event with
"message_id" not present locally, then the event was completely
ignored. But, this can happen when moving messages especially
when doing a partial move due to time limit error.

This commit updates the code to have the code which requires the
message to be present locally run only if it is present instead
of just ignoring the event completely such that the updates for
moving the messages can be done.
2023-05-05 16:18:36 -07:00
Tim Abbott 57a89e5228 message_events: Fix buggy reuse of msg local variable.
The loop through the event_messages list, as well as a few smaller
loops, used this same variable name.
2023-05-05 16:18:36 -07:00
Karl Stolley 5113f4e2e9 scheduled_messages: Render localized, streamlined modal opts.
This commit ensures that user-locale and 24-hour preferences are
respected in the message-scheduling modal. It also simplifies the
translation of text strings in the scheduling modal.

Available scheduling options and their time values, including whether
the options are allowed, are now calculated every time a user opens
the scheduling modal.

In order to achieve those things, additional interrelated fixes here
accomplish the following:

1. Modal-scheduling opts now have data- attributes containing
timestamps for the time a message will be scheduled to send.

2. With those timestamps in place, the logic for setting the
scheduled send-time is simplified.

3. There are no more `send_later_xxx` global variables in the
`schedule_send` module.

Fixes #25403.
2023-05-05 14:00:46 -07:00
Daniil Fadeev 96680e95fb message_edit: Display the error banners in the correct place.
Fixes: #25412.
2023-05-05 13:43:10 -07:00
Daniil Fadeev 0756ac9250 channel: Refactor xhr_error_message to accept message optionally. 2023-05-05 13:43:08 -07:00
Lauryn Menard a93598c22e narrow: Do not mark as read when narrowing by topic or recipient.
Previously, we've been assuming that when a user narrows to a topic
or recipient, that the target message would be marked as read in
resulting view. This is no longer a safe assumption because a user
can have their personal display settings to never mark messages as
read, even in conversation views.

Removes the call to `unread_ops.notify_server_message_read` in
both `narrow.by_topic` and `narrow.by_recipient` in the web app.
2023-05-05 13:36:31 -07:00
Aman Agrawal 36cb0f8a61 scheduled_messages: Don't narrow to recipient on "Undo".
Fixes #25401

We no longer try to narrow to the recipient of the scheduled
message when processing `Undo`. This does not affect editing
via scheduled messages overlay.
2023-05-05 12:54:35 -07:00
Karl Stolley 715fa3aff6 scheduled_messages: Extract options logic from popover.
This commit extracts date-based logic from the popover menu file and
puts it in with the scheduled-messages logic.

The aim is for greater testability, with some initial tests now
presented on the date-based logic.
2023-05-04 13:52:22 -07:00
Karl Stolley ac0bd7bb7d scheduled_messages: Show Monday option on Fridays and Saturdays.
On Fridays and Saturdays, users will be presented with the option
to schedule a message to send on Monday at 9:00 am.

Fixes: #25402.
2023-05-04 13:52:22 -07:00
Tim Abbott 2084a91af9 message_list: Don't show empty narrow message unless certain. 2023-05-03 18:40:59 -07:00
Tim Abbott 9a8749ea8f message_fetch: Fix stream narrows when everything recent is muted. 2023-05-03 18:40:59 -07:00
Tim Abbott f1033a2326 message_fetch: Avoid calling process_result for failures.
I can't see any reason why it'd make sense to call a bunch of
functions designed to process newly arrived messages with an empty
list of messages to handle a 400 error from the server.

As best I can tell, the only part of this that was useful is showing
the appropriate empty narrow message.
2023-05-03 18:40:59 -07:00
Tim Abbott fa1067ec36 message_fetch: Move connection error hiding logic.
Containing all the message_fetch logic for #connection-error inside
load_messages is considerably more readable, and will help with being
able to clean up the process_result hack.
2023-05-03 18:40:59 -07:00
Tim Abbott 4e6b27b25f message_fetch: Avoid double-fetching muted topic messages.
Previously, when backfilling in a stream narrow (the main situation
where _items != _all_items), we would double-fetch any muted messages
older than the oldest message not hidden due to topic or user muting.

We change the all_messages fetch to use this function even though it
doesn't matter, just for clarity about the intent.

Since this bug could have prevented making progress fixes a
theoretical bug that could result in the client trying to fetch
messages for a given narrow indefinitely.
2023-05-03 18:40:59 -07:00
Tim Abbott 1ce17f7403 message_list: Fix incorrect usage of visible empty check.
The core logic for deciding whether newly fetched messages should be
prepended, appended, or inserted between existing messages was wrong
in the case that the message list was only visibly empty, but its
data structures contained some muted messages.

In particular, the _all_data data structure would end up having items
appended when they should be prepended; while this would eventually be
corrected if a rerender triggered a sort, it was a data corruption
with unknown secondary consequences, and in particular would mess up
any logic correctly using the first/last elements in _all_data.

Fix this by doing all of the logic using functions accessing
_all_items.  While doing so, we simplify the logic by removing the
unnecessary special case for empty message lists, including the
parallel filter_incoming function, which added extra complexity that
should always produce the same result.

The message_list.empty helper wraps this method, and thus is corrected
as well.
2023-05-03 18:40:59 -07:00
Tim Abbott 23eaa87635 message_list_view: Fix exception prepending when visibly empty.
In an upcoming commit, we will fix a bug that caused the
message_list_data system to append rather than prepending when
previously all the messages in a message list were hidden due to
topic/user muting.
2023-05-03 18:40:59 -07:00
Tim Abbott 804f473214 message_list: Extract visibly_empty helper method.
This function will allow us to adjust the codebase to write what it
means semantically -- whether a check is for the message list being
visibly empty, or completely empty.

In this commit, we leave the .empty() method incorrect, because
several other adjustments need to be made atomically with fixing it.
2023-05-03 18:40:59 -07:00
Tim Abbott 8f1c3a0fa1 message_list: Fix selecting the first message when previously empty.
There two situations where we might add messages to a previously empty
message list. The first is when a new message comes in; in that case,
the previous logic of just selecting the first message would work.

But in the case where we're instead adding a bunch of (previously
read) messages via a backfill API request, which can occur in a few
cases, including a stream narrow where all the topics with recent
messages are muted, we should use our standard rules to pick a message
to select, namely the first unread message (if any) or last message if
none are unread.
2023-05-03 18:40:59 -07:00
Anders Kaseorg 1331f07521 unread_banner: Fix awkward phrasing and split infinitive.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-05-03 17:08:22 -07:00
Tim Abbott d24e81e1b2 unread: Fix exception handling mentions in private messages.
Private messages with mentions are included in
unread_mentions_counter, but of course don't have a stream ID, so
should be skipped when calculating which streams contain unread
mentions.

This code has always been wrong, it put `undefined` in the set of
stream IDs with unread mentions.

What changed recently is that in
98162b7a3a, we started using the
`stream_id` to do an additional lookup in the unmuted version of the
function, and doing that lookup with `undefined` threw an exception.
2023-05-03 13:29:41 -07:00
Tim Abbott 976b0662ea top_left_corner: Fix new mention animation when loading app.
Apparently some past refactor caused the animation for new mentions to
be triggered when initialization the app.

(This seems pretty clearly unintentional: A user loading the app
doesn't need their attention specifically drawn to the @-mentions view
in the same way that a user who is using the app and receives a
mention right now does.)
2023-05-03 11:12:52 -07:00
Lauryn Menard a85492ac49 scheduled-messages: Remove unused `send_later_custom` template variable.
In commit e89cbf0ac1, the only use of this template variable was
removed from `send_later_popover.hbs`.
2023-05-03 11:09:46 -07:00
Hardik Dharmani 8829190ec6 unread: Deduplicate the logic for adding up unread counts.
Deduplicated logic for calculating unread message counts and
stream counts for subscribed streams by refactoring `get_counts` to
use `get_stream_count` function for calculating unread message counts
for each subscribed stream.
2023-05-02 15:43:29 -07:00
Aman Agrawal 770a789651 hashchange: Hide popovers on change in hash.
Fixes #24641

When the user clicks on a link which has `stopPropagation`
and doesn't trigger `scroll`, then we don't hide any existing
popovers if the element being clicked doesn't hide popovers
explicitly.

To fix this, we hide all popovers on change in hash which makes sense
on its own given how we use hashes.
2023-05-02 15:41:37 -07:00
Karl Stolley cfbfc37927 scheduled_messages: Hide Scheduled messages on 0 count.
This commit introduces structures and logic to hide the Scheduled
messages item from the left sidebar if there are no messages
scheduled to be sent.

Test coverage has been added for counts and visibility, too.

Fixes: #25101
2023-05-02 15:26:33 -07:00
Karl Stolley 2d9cbfa8f1 scheduled_messages: Add left sidebar count.
This commit introduces logic to present a message count with the
Scheduled messages item in the left sidebar.

The count is present on the initial load, and is updated as a user
adds or removes scheduled messages.
2023-05-02 15:26:33 -07:00
Daniil Fadeev 6dc10f8696 compose: Pass a container to which the banner should be applied.
This fixes banners related to message editing incorrectly appearing
next to the compose box.

Fixes: #25230.
2023-05-02 14:09:09 -07:00
Tim Abbott c70910b5dc upload: Fix close widget in edit form banners not working.
The selector was wrong, but the logic also created a bunch of
duplicate click handlers.
2023-05-02 14:09:09 -07:00
Daniil Fadeev 394b3586b9 compose: Add a helper function to find the banner container. 2023-05-02 14:09:09 -07:00
Daniil Fadeev 3b35307c20 compose: Add option to specify container for appending banners. 2023-05-02 14:09:09 -07:00
Tim Abbott d96fac2b59 compose: Fix compose banner click handlers when editing messages.
The click handlers for compose banners, many of which can appear both
in the message editing code path and above the compose box, were
incorrectly scoped to only the #compose_banners container.

These click handlers were all overly specific; they already have a
very unique selector in the form of things like
.compose_banner_close_button, and more shouldn't be necessary.
2023-05-02 14:09:09 -07:00
Hardik Dharmani 3d3d30166d tooltips: Update content of `Narrow-to` toolips. 2023-05-02 13:50:46 -07:00
Hardik Dharmani 03cfb3d9fe tooltips: Add `S` hotkey hint to `narrow-to` tippy tooltips.
Added hotkey hint to Narrow to stream/topic/DM tooltips by creating
new tippy for `tippy-narrow-tooltip` with LONG_HOVER_DELAY which
appends `S` hotkey to the existing tippy content set by
data-tippy-content attribute on the element.

Using this approach instead of a <template> with
data-tooltip-template-id avoids issues with context, where
{display_recipient}/{topic}/{display_reply_to} inside <template>
would always show the same stream/topic name regardless of the
actual stream/topic being hovered over.
2023-05-02 13:50:46 -07:00