Commit Graph

142 Commits

Author SHA1 Message Date
N-Shar-ma 431cd8b10a typeahead: Don't show default emojis if overridden by a realm emoji.
When a realm emoji overrides a default emoji, `:emoji_name:` now renders
as the realm emoji. Still, the typeahead menu would misleadingly show
the now overridden default emoji for the same name. Selecting it would
render as the realm emoji, which is very confusing user experience.

Now when selecting the emojis to suggest in the typeahead, the overridden
default emojis are excluded.

Fixes part of #24120.
2023-01-31 15:52:08 -08:00
N-Shar-ma fb81e5504c typeahead: Remove misleading comment regarding favouring popular emojis. 2023-01-20 14:41:21 -08:00
N-Shar-ma aa72b51bca emojis: Prioritise custom / realm emojis when sorting.
Fixes: #18135.
2023-01-20 14:41:21 -08:00
N-Shar-ma 249f482b06 emojis: Filter out unicode emojis with same codes from typeahead menu.
Since emojis can have multiple aliases, an emoji was often suggested
under multiple names (like `smiling devil` / `smiling imp`), crowding
typeahead suggestions redundantly, and taking up the place of other
potentially relevant emoji suggestions.

Now such duplicates are removed post the sorting of suggested emojis,
and only the most relevantly named (highest sorted) copy is retained.
2023-01-20 14:41:21 -08:00
Greg Price f38b5c41da shared: Bump version to 0.0.18 2023-01-18 13:25:44 -08:00
Anders Kaseorg a5fefa5932 shared: Remove js source from distributed package.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-18 13:25:08 -08:00
Greg Price 5407d52cb4 shared: Bump version to 0.0.17 2023-01-18 13:22:47 -08:00
Greg Price 52de17e08f shared: Specify files for NPM package, so lib/ gets included
Otherwise `npm publish` and friends leave it out because it's
ignored in Git.

This also cuts out `tools/` and a few other such files.
2023-01-18 13:20:56 -08:00
Anders Kaseorg d41917ecd0 shared: Add TypeScript build step.
This transpiles the JavaScript and (future) TypeScript in
`static/shared/js` to `static/shared/lib`. It also compiles away
ES2020 syntax that’s not supported by the oldest JS engines targeted
by zulip-mobile.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2023-01-18 13:10:13 -08:00
Chris Bobbe b52e83281b shared: Bump version to 0.0.16 2022-11-02 13:59:05 -07:00
Greg Price 8810203a4c shared: Prescribe atomic push when bumping version.
This way, if the maintainer isn't able to update `main`,
the push doesn't add the shared-VERSION tag either.
That avoids ending up with a tag that potentially doesn't
get included in the history of the main branch.

The Git docs warn that servers might or might not support this
feature, but GitHub does -- indeed they boasted about it when it
first came out, in Git 2.4 back in 2015:
  https://github.blog/2015-04-30-git-2-4-atomic-pushes-push-to-deploy-and-more/
2022-11-01 22:25:37 -07:00
Chris Bobbe 167b891d4e shared: Fix typeahead.js.flow to add Emoji['reaction_type'].
The emoji matcher uses this property in is_unicode_emoji.

It doesn't quite make sense to be talking about "reaction types"
here -- we might use this for a message-reactions UI, but we might
just as reasonably use it for emoji UI in message composing. Ah,
well: I guess that's just a bit of messiness that we can deal with.
2022-11-01 17:46:47 -07:00
Chris Bobbe 72303bc0b0 shared: Bump version to 0.0.15 2022-11-01 10:19:34 -07:00
Greg Price c746d5669f typeahead [nfc]: Dissolve `query_matches_source_attrs`.
This makes each of the call sites more straightforward and
transparent.  In `query_matches_person` it also opens up further
simplifications, which we'll make next.

Since we're now exporting `query_matches_string` from this
shared module, we write its type in the `.js.flow` file.
2022-10-31 10:28:03 -07:00
Greg Price 7400165031 typeahead [nfc]: Push toLowerCase down into query_matches_string.
This prepares us to dissolve query_matches_source_attrs in favor
of making its call sites simpler and more transparent.
2022-10-31 10:28:03 -07:00
sayamsamal c8f346b5e5 icons: Change mute icon from bell to speaker.
This icon is more standard, and lets us use a speaker icon for other
applications.

Fixes #21751
2022-09-09 17:32:19 -07:00
Anders Kaseorg 143a3350fa dependencies: Upgrade JavaScript dependencies.
jQuery is held at 3.6.0 due to
https://github.com/jquery/jquery/issues/5105.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-09-06 15:02:29 -07:00
Dinesh 48d2783559 read_receipts: Add support for displaying read receipts.
Adds an API endpoint for accessing read receipts for other users, as
well as a modal UI for displaying that information.

Enables the previously merged privacy settings UI for managing whether
a user makes read receipts data available to other users.

Documentation is pending, and we'll likely want to link to the
documentation with help_settings_link once it is complete.

Fixes #3618.

Co-authored-by: Tim Abbott <tabbott@zulip.com>
2022-08-12 13:16:35 -07:00
Aman Agrawal 59e676b1f5 gear_menu: Allow spectators to select their default language.
Set the default_language as cookie and reload the page so that
the spectator can immediately see the language change in effect.

We can reload the page forcefully for spectators since there is
no chance of any work being lost. It is possible that the spectator
may lose the selected message on doing so.

This requires a new dependency, to be able to set cookies from
frontend JavaScript.

Fixes #21961
2022-06-01 17:08:00 -07:00
Lani 5a9cba1bba emoji_picker: Allow filtering emojis by unicode characters in emoji picker.
This PR implements literal emoji match in the emoji picker (for reactions)
and in emoji typeaheads (in compose box)

Tested on mobile browser by opening the emoji picker with the
reaction button, selecting an emoji via the native keyboard, and
ensuring the selected emoji appears in the emoji picker’s search
result.

Fixes #21714.
2022-05-31 10:02:57 -07:00
Anders Kaseorg 4c307e5266 shared: Check variable in release scripts, avoiding shellcheck disable.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-04-26 16:39:18 -07:00
Greg Price f9ae386050 shared: Fix lint errors in new NPM scripts.
Oops!
2022-04-25 10:10:03 -07:00
Greg Price 3fbbfb8ad3 shared: Bump version to 0.0.14 2022-04-25 09:57:43 -07:00
Greg Price ed68a18de4 shared: Bold postversion output, to try to stand out in npm's noise. 2022-04-25 09:57:33 -07:00
Greg Price dbe92ebbfe shared: Script up the NPM release process for `@zulip/shared`.
This will replace about a half-dozen steps of these instructions:
  https://github.com/zulip/zulip-mobile/blob/ec1370159/docs/howto/shared.md#publish

with "run `npm version patch`; then run the commands it prints."
2022-04-25 09:37:35 -07:00
Greg Price ce2014bfef typeahead: Normalize spaces for sorting emojis, just like for filtering.
And add a pair of tests.  The first one (with an underscore) passed
already; the second (with a space) passes only with this change.
2022-04-21 17:59:28 -07:00
Greg Price 0f6483449f typeahead: Lower-case query in sort_emojis more consistently.
This makes this function easier to reason about, by having only one
version of the query floating around.

The change is nearly NFC: the one other place this `query` parameter
is used is the `triage` function, and that already lower-cases the
query too.

But `triage` has some additional case-related behavior: among prefix
matches (but not among exact matches), it moves any that match
case-sensitively ahead of any that don't.

As long as all emoji names are lowercase -- as all our built-in
emoji are, and as all custom emoji probably are in most realms --
that still has no effect: either the query is lowercase too and all
matches are case-sensitive matches, or it isn't and none of them are.

But it can show up if someone adds a custom emoji like `:GitHub:`
or `:LaTeX:` (like we have a `:github:` in chat.zulip.org), and then
someone does the natural thing of searching for them in lowercase.

When the behavior does show up, it seems like it can only come
across to the user as a glitch: the emoji that have capital letters
get weirdly taken out of order and moved to the end, or just don't
show up if there are more than 8 results.

In general I'm not convinced there are any situations at all where
this behavior of `triage` makes sense: basically every other
search UI in the computing universe is case-insensitive except for
some aimed at programmers searching through code, and none of our
typeahead searches are aimed at doing that.  But for the moment,
just simplify the emoji case in particular.
2022-04-21 17:59:28 -07:00
Greg Price dc6e9df43a typeahead: Don't stop midphrase matching when a second word is typed.
For example, if a user's name is "Simon Peyton Jones", we'll already
match that name on the queries "Pey" or "Peyton", as well as on
"Simon P".  We should do so on "Peyton J" or "Peyton Jones", too.

Similarly, if the user is looking for an emoji of a face in the moon
and they start by typing ":moon", we'll show them both 🌝 "moon face"
and 🌚 "new moon face", along with some other moon-related results.
If they go on to make it ":moon " or ":moon f", though -- as one very
naturally would in order to eliminate things like "waxing moon" and
"moon ceremony" -- then we mysteriously eliminate 🌚 "new moon face".
Instead, the query "moon f" should match both 🌚 and 🌝.

Found this while comparing the web/shared implementation with the
mobile implementation of emoji search.  The new behavior here
reflects what we already do for emoji search in mobile, both in the
compose box's typeahead and in the add-a-reaction screen.  The
existing behavior here seems pretty annoying, so fixing it will be
part of switching on mobile to the shared code (zulip/zulip-mobile#4636)
without regressing the user experience.

The current behavior was introduced, more or less, in 245d65eb9; then
revised in 5edbcb87f to make the logic more clear, and a fix made in
542f4766d, all 2018.  The PR thread was #8286, following issue #8279.
The old behavior before those changes was pure substring matching,
plus a trailing space was ignored (which is the part the issue was
about.)  None of the discussion touches on this question; as far as I
can tell, the fact that "Peyton J" doesn't match "Simon Peyton Jones",
nor "moon " match "new moon face", was entirely an unintentional
side effect of those changes.
2022-04-21 17:59:28 -07:00
Greg Price 9c206ca8e5 typeahead [nfc]: Simplify query_matches_string logic.
This comment was widely separated from the code it's describing, which
is the `return source_str.includes(query)`.
2022-04-21 17:59:28 -07:00
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
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
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 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 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
Greg Price 3ff2bcf62a shared: Bump version to 0.0.10. 2022-03-30 21:06:37 -07:00
Aman Agrawal 6fcbe4091d web_public_streams: Change globe icon.
This revised globe icon avoids looking like a "language choice" icon
(as the previous one did), while still being recognizably Earth (and
not a disk with some things drawn on it) and not showing only North
America (a flaw with the Font Awesome 4.7 icon).

Used a derivative of icon from
https://unpkg.com/ionicons@5.5.2/dist/svg/earth.svg
with modified outline by Vlad Korobov.
2022-03-22 16:15:55 -07:00
Aman Agrawal 9a7fadbbeb zulip-icons: Move custom icons to shared folder. 2022-03-22 16:14:56 -07:00
Anders Kaseorg 7aa03e9d2a dependencies: Upgrade JavaScript dependencies.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
2022-03-17 15:24:46 -07:00
Greg Price d583fcec59 shared: Bump version to 0.0.9. 2022-03-11 17:27:08 -08:00
Austin Riba 4301148bee shared: Add first Flow types for typeahead module
[greg: simplified to just the function we need right now,
 leaving the rest for later]
2022-03-11 17:23:16 -08:00
Greg Price a71fad9d6b shared: Bump version to 0.0.8. 2022-03-08 20:35:10 -08:00
Greg Price 760cfcc603 resolved_topic: Implement resolve, unresolve, and display.
We have two different frontend implementations of computing the
un-resolved form of a topic name, and they have a subtle -- but
intentional -- difference in behavior.

Factor them both out into the resolve_topic module, along with
their inverse, and with comments and tests.
2022-03-07 21:35:00 -08:00
Greg Price 7bf0fd3fa3 resolved_topic: Add and use predicate is_resolved.
We leave in place a couple of sites where the `startsWith` is
entangled with other string manipulation.  We'll handle those next.
2022-03-07 21:35:00 -08:00
Greg Price 624cdb0a14 resolved_topic: Start module, in shared package.
For the moment, just move the RESOLVED_TOPIC_PREFIX constant.
More next.
2022-03-07 21:35:00 -08:00
Greg Price dd1091c59a shared: Add a gitignore, for node_modules. 2022-03-07 21:35:00 -08:00