Added function parameter types, return type, and types of local
varaibles. Added a `null` check for `raw_data` before `JSON.parse`.
Created a type `FormData` and an export type `LocalStorage` to
imporve conciseness and clearity.
Type `LocalStorage` is exported because it might be used in other
files based on an observation that many files have imported `localstorage`.
This commit converts the dynamic closed_compose_box
tooltip to template-based tippy.js tooltips. The functions in
the compose_closed_ui.js file are refactored to dynamically change
the 'data-tooltip-template-id' attribute according to the situation.
The title parameter is removed from the functions in
compose_closed_ui.js so that we can change the tooltip within the
caller functions themselves, according to the situation. Since there
is no way to match the title in existing functions with different
languages to change the tooltip attribute dynamically, it is better
to change the tooltip attribute within the caller function according
to the situation, rather than passing the title as a parameter.
In the case of the reply button, we disable it when direct messages
are not allowed. However, tippy.js tooltips do not appear in the
case of disabled elements, so we have to use the container element
around it to show the tooltip. This approach is used in the case of
the reply button, where the span element wraps the button.
We used to have two titles for the reply button: one is the usual
'Reply to selected message', and the other is for the disabled state.
However, in the case of recent conversations, it makes more sense
to have a new tooltip title: 'Reply to selected conversation'.
To ensure that the tooltip content changes dynamically, it is
required to destroy the tooltip instance and then reinitialize it
every time.
Fixes: #25096
If there are unread_mentions in unmuted topic in muted stream then,
show `.subscription_block unread_mention` in regular font not faded.
An additional parameter is passed to the update_count_in_dom function
to add or remove the "has-unmuted-mentions" class from the
.subscription_block, allowing for the relevant CSS to be applied to
display the unread mentions in regular font.
Fixes part of #24243.
This commit implements a new logic to display unread messages count
in muted streams. If there are any unread messages in unmuted topics
within a muted stream, the unread counter for the stream will display
the total count of all the unread messages in the unmuted topics.
The counter will be shown in regular font (not faded).
Fixes part of #24243.
Co-authored-by: Tim Abbott <tabbott@zulip.com>
Add class unmuted_topic to li.bottom_left_row element if topic is
unmuted. Add relevant CSS for .unmuted_topic to display unmuted
topics in regular font.
Fixes part of #24243.
Previously, muted streams in the left sidebar were faded using
opacity: 0.5, and on hover, the opacity was increased to 0.75.
This opacity was applied to all elements within the muted stream,
including the stream-privacy icon, names of the stream and topics
within, and the unread_count.
In this PR, we changed this behavior to handle opacity for each
element separately. We changed the opacity of the stream-privacy icon
and unread_count, while for the text (names of stream and topics),
we changed the alpha factor for the hsla color property.
The reason for this change is that we can have different opacity levels
for the unread_count and other elements. This will allow us to add
feature in next commits in this PR to set the opacity of unread_count
to 1 while keeping it at 0.5/0.75 for other elements in the case of
muted streams with unread messages in unmuted topics.
Fixes part of #24243
We should trigger click event to open up the dropdown popup instead of using
`.dropdown("toggle")` because we want to clear the search state when opening up
the popup and the logic for that is registered in `on-click` handler defined in
`dropdown_list_widget`.
Fixes: #25218
Since we currently have 3 unread banners, it'd be much preferred to group
all of them up into one folder to keep them organized like how compose
banners are. This way, it's much easier to keep track of unread banners
and new ones in the future.
After merging #24309, we want to add an additional option to the "mark
messages as read on scroll" setting where we only mark messages as read
on scroll in conversation views.
`copy code` button now show a `Copied!` tooltip when clicked.
It implements a similar function used on `saved as draft` notice.
We need to modify the copy_code_button template to limit
data-tippy-trigger to not include click; otherwise, repeated clicks to
copy code will incorrectly also display the "Copy code" tooltip
alternating with "Copied".
Fixes part of #21036.
When we send a message (for which notifications are enabled)
in format `[](file_url)`. A blank notification is sent.
Fixing this by checking if there is no text and adding
message in that case.
Inspired from: #8796.
Fixes: #8087.
Without this, if there was a success compose banner and user pressed
escape key, no banners were hidden and the same behaviour was repeated
without compose ever closing.
Previously, when a user marks messages as unread in the all messages view
then enters another view and finally back to the all messages view, they'd
notice that the reading state in all messages view is still paused.
This happened uniquely for "All messages" because we only resumed the "reading"
state in `narrow.activate` (and generally that would generate a new MessageList anyway);
but `message_lists.home` is a singleton, so the "no longer reading" state would remain
attached to that object forever.
Fix this by explicitly resuming the reading state when we enter all messages
view/message_lists via narrow.deactivate.
Set data-tippy-trigger="mouseenter" on mute icon in recent
conversation to prevent tippy from staying on when the mute icon
is focused after clicking it. (The Tippy default is "mouseenter focus").
Rename get_muted_topics to `get_user_topics_for_visibility_policy()`,
since it works for both muting and unmuting.
Additionally, inline rerender_for_muted_topic, as well as removing
most of the logic to diff the sets of muted topics; the event is for a
single topic being changed.
Co-authored-by: Hardik Dharmani <Ddharmani99@gmail.com>
This commit refactors the logic of the 'all messages' view to
display messages from unmuted topics within muted streams.
Previously, we hid all messages from muted streams except mentions
by checking if the stream was muted. With this new change, we also
check for unmuted topics within muted streams using the
'is_topic_unmuted' function inside 'user_topics', which returns
'true' if the topic is unmuted. If there is any unmuted topic, we
show the messages from that topic in the 'all messages' narrow.
Live update was handled by the previous commit.
Fixes part of: #24243
We can dramtically simplify the stream muting live-update code path
for updating home_msg_list by observing the only thing it was doing
intentionally differently from update_muting_and_rerender is replacing
_all_items with a new version computed from from all_messages_data,
and the rest of update_muting_and_rerender can handle the live update
correctly unmodified.
This deduplication means live-update of "Unmute topic" just requires
updating the `in:home` filter logic appropriately, without any special
live update work.
Previously, the email had a line that says "Click the button below". This
sounds weird as the plain text emails don't have buttons and only had links.
We should change "Click the button below" to "Click the link below" which
makes more sense.
Created a new function choose_topics that loops through the topics
and push filtered topics using should_show_topic function to items
array if not zoomed else just push all topics directly to array.
If stream is muted and not zoomed call the choose_topics function
twice, first with passing unmuted_topics and second time with passing
remaining topics. else, call it only once with topic_names.
Fixes part of #24243
When user marks messages as unread, we used to rerender them but
that was not required since we only need to add `unread` class
to their `message_row` to achieve the same effect.
When selecting a previously selected message after a re-render,
we don't need to mark it as read. This caused a bug where
user cannot mark the selected message in a narrow as unread.
Also, added an additional check to only select messages if the
message is re-rendered in the currently visible message list since
you cannot select a message in a view which is not visible.
Updates areas in the API documentation that reference the maximum
length of a stream message topic to note the `max_topic_length`.
Updates areas in the API documentation that reference the maximum
length of a stream name to note the `max_stream_name_length` and
areas that reference the maximum length of a stream description to
note the `max_stream_description_length`.
All of these maximum values are sent by the `POST /register`
response.
We now open the stream dropdown if a user presses "Shift+Tab" from
topic input in the compose box, instead of just changing the focus
to be on dropdown toggle button.
This helps reduce the amount of import cycles we have in the compose
code path following the migration to a fancier stream input.
`compose_closed_ui.initialize()` was moved further down in the
initialization order because it relies on the dropdown widget
to be defined.
This is needed for the compose stream dropdown widget,
which is also updated here. Now when a user is subscribed
or unsubscribed from a stream, or a stream is renamed, or
or a stream is deleted, the dropdown widget updates
accordingly. This fixes a regression of this functionality
that happened during the switch to the dropdown.
These were previously used in the input form field and
this commit removes the code that supported that and
replaces it by using existing dropdown_widget functionality
to display the icons in the compose dropdown.
Fixes#11832
This lets the user see more options than the three that appear
in the typeahead menu, and prevents them from inputting invalid
stream names.
This change replaces the input field with the dropdown, and
updates everything that referred to the classnames of the old
input field, so that they now get the data they need from the
new dropdown.
Previously, we stopped the composebox from closing on
in-composebox clicks by stopping propagation from the
composebox click handler. This was an issue because
we need to propagate the event to bootstrap in
situations like dropdown clicks. We can avoid closing
the composebox on in-composebox clicks by just checking
if the click is in the composebox.
This is a helpful prep commit for the upcoming compose
stream dropdown, which needs to change the list of
stream names when the user changes their stream subscriptions.
After merging #24423, it was found that there were still an email yet to be updated with the new lines introduced in that PR. This commit updates both the email and plain-text versions.
This is a continuation of #24260 where we have redrafted the "contact us"
line in various emails, but the plain-text versions of those emails remains
untouched. We want to also update those versions and ensure that they match
with our emails.
Fixes: #25198.
This commit sets the transition to "none" for the dropdown
list widget element during focus to remove a weird fade-in
effect. We have to set this to none as the existing CSS
sets transition for all button elements inside ".new-style"
div. This commit adds the CSS for select element too,
as both are using same CSS, but since there was no transition
effect for select elements before as well, we can do this
change safely.