Commit Graph

13643 Commits

Author SHA1 Message Date
Anders Kaseorg eda000899b actions: Split out zerver.actions.message_edit.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-14 17:14:36 -07:00
Austin Riba 12c563cc94 Revert "shared: Match literal emoji in typeahead."
This reverts commit a8fd535955.
This reverts commit 944781e873.

In an attempt to introduce code from mobile into web to match literal
emojis, the author inadvertently introduced a buggy and smelly change.
Probably best to leave the implementation of this in mobile where there
is more context about the shape of the emoji object available. Web
doesn't actually benefit from the additional behavior anyway.

See https://github.com/zulip/zulip/pull/21723#pullrequestreview-937051603
2022-04-14 11:51:40 -07:00
somesh202 b4aeb7a622 compose: Remove "stream" mention in case of PMs.
This commits adds an wildcard_mention_array which would contain the
mention tokens according to the message type. In case of PMs, it uses
only "all" and "everyone" mentions.

Fixes part of #21643.
2022-04-13 16:06:05 -07:00
somesh202 5bddd8fa48 compose: Fix "Notify" string in wildcard mentions typeahead for PMs.
This commit attempts to fix the suggestions typeahead for wildcard
mentions in case of PMs by using a conditional which checks for the
current compose_state and changes the string in parentheses accordingly.
In case of PMs, it uses the "(Notify recipients)" string instead of
"(Notify stream)".
2022-04-13 16:06:05 -07:00
aparna-bhatt 80bbca22f7 flatpickr: Use 24-hour time in time picker when appropriate.
We just need to translate the Zulip setting to the appropriate
`flatpickr` option.

Fixes #18960.
2022-04-08 15:01:36 -07:00
Austin Riba b4a8817ec9 shared: Bump version to 0.0.13. 2022-04-08 12:51:59 -07:00
Austin Riba 944781e873 shared: Do not throw exception in parse unicode.
There is no guarantee that the code passed into parse_unicode_emoji_code
is valid unicode. In the case that it is not, it might be better to
return undefined instead of throwing an exception: to represent a
non-parseable code.

For context, mobile currently returns custom emojis as emojis with
string names in their code property, instead of actual unicode.
2022-04-07 17:23:55 -07:00
Sdrummolo cb29eb9434 compose: Fix top right button positioning with long PM recipients.
Previously, these buttons were centered via flex, which meant that in
the rare case that a long list of private message recipients caused
the recipient area to line-wrap, these icons would be incorrectly
placed at the vertical center of the now multi-line block.

Fix this by setting an auto bottom-marging.

Fixes #21693.
2022-04-07 13:21:58 -07:00
jai2201 c6f2b9c636 left-sidebar: Use same logic as of Topics view to render PMs.
Change the logic for rendering PM threads in PM section to
be in the same as that of topics view --
In default view, only recent 5 PM threads would be shown
and append the active conversation as the 6th one at last
if not present in those 5.

In PM section with unreads, a maximum of 8 conversations
would be shown and rest of them would be hidden behind
the 'more conversations' li-item, clicking on which takes
to the zoomedIn view of PM section where all the present
PM threads would be visible.

Co-authored-by: Tim Abbott <tabbott@zulip.com>
2022-04-06 16:51:15 -07:00
Tim Abbott 3388eaf644 pm_list_data: Rename display_message => display_object.
We try to keep the term "message" in variable names reserved for
things that are actually Zulip messages.
2022-04-06 16:51:15 -07:00
Tim Abbott 64cdb9a919 left sidebar: Rename convos => conversations variable names.
This name violated our policy against abbreviations.
2022-04-06 16:51:15 -07:00
Aman Agrawal 4a73fd9e10 overlays: Add `is_modal_open` check along with `is_active` check.
This applies the fixes we have when restoring scroll position and
marking messages as read in background for overlays to modals.
2022-04-06 14:27:20 -07:00
Austin Riba a8fd535955 shared: Match literal emoji in typeahead.
This PR implements checking for a literal emoji match in emoji
typeaheads. In other words, if you paste or type panda face into an
emoji typeahead, panda face should be presented as an option to choose
from.

This behavior is currently present in the mobile app, adding it to
shared will enable both platforms to utilize this logic.
2022-04-06 14:25:29 -07:00
Greg Price 00c017f83c apps: Link to release page for Android, rather than directly to APK.
The old link here broke once we introduced separate APKs per ABI,
in zulip/zulip-mobile#5296.

We could make a direct link to app-armeabi-v7a-release.apk , the one
that's compatible with almost all devices.  But perhaps better is to
just go back to linking to the release page, where the user can
choose the best APK for their device.  (If they're in the habit of
downloading APKs manually to install on their device, then probably
that means they're going to be used to choosing the right one.)

User report and discussion:
  https://chat.zulip.org/#narrow/stream/48-mobile/topic/Direct.20apk.20download.20link.20is.20404/near/1358758
2022-04-05 17:52:52 -07:00
Steve Howell b7e2f8dfa6 markdown: Have users report marked errors to Zulip.
marked.js provides a helpful error message asking for bugs to be
reported upstream, but since we're running a fork, we should redirect
such support requests to us.

We can triage as necessary.
2022-04-05 11:45:59 -07:00
Steve Howell c7ed21f891 markdown: Avoid blueslip dependency.
If katex throws an error that we can't deal with,
we just re-throw it now.
2022-04-05 15:22:53 +00:00
Steve Howell 83e3deab44 markdown: Remove last uses of helpers global. 2022-04-05 13:44:48 +00:00
Steve Howell 918de49f6b markdown: Nest get_linkifiers_regexes().
This makes parse() more re-entrant.

This also drives out a change to the linkifiers
test, where I no longer couple the linkifiers
logic to markdown concerns. I probably should have
done this in an earlier commit, but better late
than never. I didn't bother to split out a commit
for the test stuff, since it's just tests and
the commit is still fairly atomic in nature.
2022-04-05 12:42:15 +00:00
Greg Price 308c0614ec shared: Bump version to 0.0.12. 2022-04-04 18:12:28 -07:00
Austin Riba 27494b8b50 typeahead: Add Flow types for get_emoji_matcher and sort_emojis.
This will let us use these in mobile.
2022-04-04 18:11:17 -07:00
Greg Price 8bc2ac4b8d shared: Bump version to 0.0.11. 2022-04-04 15:39:23 -07:00
Greg Price d1c326a6cd poll_data: Write down types for Flow, for mobile.
These are based on my reading of the poll_data.js implementation.
2022-04-04 15:37:42 -07:00
Steve Howell 17b60efdc7 markdown: Inject function for emoticon translations.
We want our parser to be as re-entrant as possible.
2022-04-04 14:07:18 -07:00
Steve Howell 03c15c8c14 markdown: Rename r to renderer. 2022-04-04 14:07:18 -07:00
Steve Howell 214ec099bb markdown: Eliminate setup() call.
It has always been pretty arbitrary what we did inside
of setup() vs. parse(), and we want to avoid unpredictable
results from other platforms neglecting to call setup().

On my machine you can parse a simple message in about
25 microseconds, based on a trial of a million messages
with the content of "**bold**".  Whatever portion of
that time is related to setup-related things like
compiling regexes should be negligible from the user's
perspective, since we never run parse() in a loop.
2022-04-04 14:07:18 -07:00
Steve Howell 093eba077a markdown: Avoid needless code duplication.
We only need to loop through the preprocessors
once, and we should use the options passed
in to the parser, not the default options
from the original setOptions call.

The first loop here was doing nothing.
2022-04-04 14:07:18 -07:00
Steve Howell a77bf90601 markdown: Narrow stream/user_group types for mobile.
Our sub (i.e stream) and user_group objects have a bunch
of fields that aren't relevant to markdown parsing, so
we create narrow types that make it easier for us to
share code with mobile in the future.

I considered working purely in id space, but the problem
there is that user-entered stream names and user group
names need to be canonicalized.
2022-04-04 14:07:18 -07:00
Steve Howell 2bfdbbe7dc markdown: Extract get_topic_links. 2022-04-04 14:07:18 -07:00
Steve Howell 326dbfb934 markdown: Use options, not rules, for linkifier regexes.
This avoids the need to set a global from linkifiers.js.
2022-04-04 14:07:18 -07:00
Steve Howell 029b3e79a9 markdown: Add abstract_map() concept.
The abstract_map() helper clarifies that our code
doesn't need a concrete Map object from JS. This
change is possibly premature until we get a little
bit closer on integrating with mobile, since it
solves kinda the same problem that we might handle
more elegantly with TypeScript or Flow.

OTOH I find it to be pretty non-intrusive for the
webapp.
2022-04-04 14:07:18 -07:00
Steve Howell 3884710033 markdown: Inject linkifiers helper. 2022-04-04 14:07:18 -07:00
Steve Howell 1156001840 markdown: Inject emoji helpers.
Note that we try to avoid the helpers global, but we
still need a future commit to further clean things up.
2022-04-04 14:07:18 -07:00
Steve Howell 94f1fe6891 markdown: Avoid helpers global in some places.
These are the low-hanging-fruit places where we
can avoid using the helpers global.

The long term goal here is to make the markdown
code truly re-entrant, but some challenges still
remain.
2022-04-04 14:07:18 -07:00
Steve Howell cc51e89730 markdown: Set handlers at parse time.
This will help us make the code a bit more
re-entrant in future commits.
2022-04-04 14:07:18 -07:00
Steve Howell 38a3d89a13 zcommands: Fully parse messages from the server.
Before this change, we would use **some** options relating
to parsing messages, but not all of them.  The reason for
this was completely unintentional.

It's mostly a moot point, since the server sends back pretty
generic messages when you do something like invoke the
"/dark" command, and the message would parse the same way
whether or not the parser was looking for things like user
mentions or stream links.

In order to make this code predictable, I had to decide
whether we do a completely vanilla parse or a full message
parse. My decision now is mostly tactical. It's a trivial
one-line change to just use all the options for message
parsing, whereas it requires a major overhaul to allow a
vanilla parse.

I also predict that we will eventually want to parse these
server responses as if they were messages. I doubt the
zcommand responses would ever take advantage of it, but I
could imagine things like nag messages wanting to use user
mentions.

Even if my predictions are wrong, my decisions here are
pretty easy to reverse once we learn more.

For the particular case of zcommands, it is puzzling to me
why the server doesn't just send back HTML, but I don't want
to open that can of worms yet, as that would technically be
an API change.

For now I am happy with the one-line fix.
2022-04-04 14:07:18 -07:00
Steve Howell 06ba05b44d markdown: Extract parse_non_message().
The zcommand code was calling directly into the "marked"
library, which was extremely misleading, since you don't
get a vanilla parse of the markdown due to the fact
that markdown.js calls setOptions at initialize time.

This commit shifts the responsibility to markdown.js
as well as adding a bit of test coverage, but it is
otherwise just a pure code-move refactoring.

The next commit will tweak things further.
2022-04-04 14:07:18 -07:00
Steve Howell cf1149539e emojis: Swap the loops to build the emojis map.
This is mostly done for correctness reasons--it is
easiest from a logical standpoint to set the realm
emojis at the end of the function, since we do not want
them to be overwritten by normal emojis. The code
worked before this change, but it involved a clunky
check to map.has().

There is also probably a very minor performance
improvement insofar as N (the number of normal
emojis) is typically greater than R (the number
of realm emojis), and we eliminate N calls to
map.has in return for R calls to map.set.  Even
if R is quite large, the readability advantages
probably far outweigh any performance considerations,
since we are using native map calls.

Thanks to Austin Riba for this suggestion.
2022-04-04 13:28:49 -07:00
Steve Howell 3f6d0939fc emojis: Extract build_default_emoji_aliases(). 2022-04-04 13:28:49 -07:00
Steve Howell e7738981b7 emojis: Make build_emojis_by_name() a pure function. 2022-04-04 13:28:49 -07:00
Steve Howell d10e7ef85c emojis: Make build_emoticon_translations() a pure function. 2022-04-04 13:28:49 -07:00
Steve Howell c943447c6e emojis: Un-share the emoji.js module.
The mobile app was never able to use the shared
version of emoji.js, because, among other problems
with our code organization, the emoji.js module
is strongly based on a mutate-the-data paradigm
that doesn't play nice with React.  The way
that we mutate data and violate encapsuation
here is something that we would mostly want to fix
without even trying to shared code with mobile, so
subsequent commits will try to extract some pure
functions into a shared module.
2022-04-04 13:28:49 -07:00
Archisman Das 491b1513eb settings: Fix length of custom profile field URL input.
The backend validates that URL inputs are RFC valid URLs (with no
specific length limit), but the frontend appears to have a maximum
length of 50 specified, likely because of a copy-paste error.

Increase the HTML maxlength for this input to 2048, which is a length
supported for URLs by all major browsers.

Fixes #21633
2022-04-04 12:10:05 -07:00
Sahil Batra c3efd6b6a4 i18n: Translate the whole text in stream deactivation modal.
This commit fixes the template of stream deactivation modal
to tag all the text for translation. This commit also removes
the unnecessary span element.
2022-04-04 11:57:19 -07:00
NerdyLucifer c79849dab6 settings: Replace "Delete bot" with "Deactivate bot".
The feature deactivates the bot user; Zulip has no "delete bot"
feature. So fix the label to match what it does.

We also change the icon to match the one we use for deactivating users
in the "Manage users" UI.
2022-04-01 15:03:23 -07:00
Sahil Batra 3a3ed78fd9 stream_settings: Live update the banner on changing subscription. 2022-04-01 14:52:06 -07:00
Palash 4d44698805 stream_settings: Remove pencil icon from 'General' tab in stream settings.
For user who is not an administrator.
Also implemented a banner that notifies the user if they can edit
the following settings (name/description and stream permission).
Also increased padding-top of stream header by 10px. This change is done
to increase vertical spacing between the banner
and the stream header.

Fixes #20001.
2022-04-01 14:52:06 -07:00
Aman Agrawal 2df4ace441 navbar_alerts: Adjust height of recent topics when alert is visible.
Fixes #21619

We need to adjust height of recent topics along with the app
otherwise the container becomes separately scrollable due to
it overflowing the app height.
2022-03-31 11:25:09 -07:00
Heidi Ahlberg 9e6836d0af i18n: Fix missing translation tags in stream creation view. 2022-03-31 10:33:34 -07:00
Greg Price 3ff2bcf62a shared: Bump version to 0.0.10. 2022-03-30 21:06:37 -07:00
Steve Howell b7f670f5a0 markdown: Extract set_linkifier_regexes.
This is definitely better than having linkifiers
reach directly into marked.js, but there is
probably further improvement we can do here
to clean up how these regexes get set.

This introduces a circular dependency between
markdown.js and linkifiers.js, but we will
soon break it in the other direction.
2022-03-30 14:31:00 -07:00