Earlier, when a topic had less than 15 participants,
the @-topic typeahead was not visible. It should be visible
irrespective of the 'realm_wildcard_mention_policy' setting
when the participant count is not greater than 15.
The participant count for a topic can't always be calculated
accurately in the client as some of the messages might still
be loading.
We show @-topic in the typeahead whenever it might be possible
to use it.
We will give an error later if you aren't allowed to use it.
Fixes#27852.
This prep commit renames:
* 'stream_wildcard_mention_allowed_in_large_stream' to
'wildcard_mention_policy_authorizes_user' because the function
checks if the sender is allowed to use wildcard mentions based
on the 'wildcard_mention_policy' setting, and we plan to use that
for topic wildcard mentions too.
* 'stream_wildcard_mention_large_stream_threshold' to
'wildcard_mention_threshold' because this value is going to be
used as a threshold value for the max number of subscribers and
participant count allowed for stream and topic wildcard mention
respectively.
We simplify the banner message by replacing the
"stream wildcard mentions" text with `"@stream mentions`,
`"@-all mentions"`, or `"@-everyone mentions"` text.
Earlier, a 'large @-mention notification' warning that pops up
for stream wildcard mentions was shown for topic wildcard mentions
too, which is incorrect.
This commit fixes the incorrect behavior. We no longer show the
banner for @-topic mentions.
We don't need a banner for @-topic mentions, as those are much less
likely to be used without thinking about it and would rarely be spammy
for a lot of people.
Fixes#27767.
Earlier, the send button's state was determined independently by the
message length and the upload status, and its containing `div`'s state
was separately determined on recipient change by whether the user had
permission to post in that stream, or if direct messages were allowed
in the organisation. The main problem was that as the message length
check was run on each character input, it often overrode the upload
status check.
Now for consistency, the code has been refactored to always disable the
send button by accordingly styling its containing `div`; and using the
observer pattern we update it anytime the message length, upload status,
or the recipient changes, considering **all** of them together.
(The Save button when editing a message still works like before -- only
dependent on upload status.)
Fixes: #21135.
We refactor the code checking if wildcard mentions are allowed by
renaming the pre-existing function `wildcard_mention_allowed` to
`wildcard_mention_allowed_in_large_stream`, adding a new function
`is_recipient_large_stream`, then redefining `wildcard_mention_allowed`
to combine these two functions.
Fixes: #27248.
We should make `get_by_user_id` type-safe in the sense that it's caller
should not expect undefined values and hence it's caller should not
need to validate the user ids.
To do this I extracted a method `maybe_get_user_by_id` which is
type-unsafe version of this function which will allow undefined values
and will behave exactly the same as the previous version. So the callers
which expects the undefined values from this function should use this
new function `maybe_get_user_by_id`.
Probably about half of these callers are implicitly iterating through
all users in the people.js data set and thus by construction should
never fail, but it's simpler to just convert all existing callers than
do that audit.
This commit addresses the issue of relying on `compose_state` for
retrieving the `stream_id` to display warning banners. Previously,
warnings were shown for syntax in the message edit box based on
whether that syntax would trigger a warning for the draft content (if
any) currently in the compose box.
We fix this by using a new `get_stream_id_for_textarea` function to
obtain the correct `stream_id` value for the check being done.
Fixes: #25410.
`update_or_append_banner` abstracts the logic for not creating another compose
banner if one is already present in the DOM, it just replaces the content of the
old banner with the new one.
This commit introduces a new container parameter for functions that
can be used for both compose and edit mode. It provides the function
with information about the context in which it is being used.
Previously this dropdown was only for selecting streams, but
soon it will also be for switching to a private message. This
name helps it be clearer that the dropdown is more general
purpose.
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.
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.
This lets us simplify the long-ish ‘../../static/js’ paths, and will
remove the need for the ‘zrequire’ wrapper.
Signed-off-by: Anders Kaseorg <anders@zulip.com>