Commit Graph

146 Commits

Author SHA1 Message Date
Joffrey JAFFEUX 630bde1ba2
PERF: do not cancel debounce and prevents popper on scroll (#19280)
This commit also replaces deprecated `mousewheel` by `wheel` event listener
2022-12-01 14:33:46 +01:00
David Taylor 07fb7fc54d
DEV: Colocate all chat component templates (#19266) 2022-11-30 17:55:07 +00:00
David Taylor 2b53c2cfca
DEV: Enable `@cached` decorator for themes and plugins (#19261)
`ember-cached-decorator-polyfill` uses a Babel transformation to apply this polyfill in core. Adding that Babel transformation to themes and plugins will be complex, so we use this to patch it at runtime. This can be removed once `@glimmer/tracking` is updated to a version
with native `@cached` support.
2022-11-30 15:53:54 +00:00
David Taylor 105f500693
FIX: Show chat channel info on reviewable items (#19260)
`reviewable.chat_channel` is a plain javascript object from the server's JSON response. We need to turn it into a true `ChatChannel` object before passing to `<ChatChannelTitle>`

This commit also converts `<ReviewableChatMessage>` to a Glimmer component
2022-11-30 14:08:30 +00:00
Keegan George 7a8e018965
UX: reworks channel index (drawer and mobile) (#18892)
- Multiple style improvements
- adds last sent message date to the view

Co-authored-by: chapoi <charlie@discourse.org>
Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2022-11-28 18:38:05 +01:00
Joffrey JAFFEUX 0cb6d8c8fc
FIX: prevents audio to play when appended (#19199) 2022-11-28 09:22:13 +01:00
Joffrey JAFFEUX b032115506
DEV: removes select-kit deprecation (#19200) 2022-11-26 15:17:43 +01:00
Joffrey JAFFEUX 637fb9831b
FIX: ensures chat sidebar is present when core sidebar is disabled (#19197) 2022-11-25 19:28:10 +01:00
Joffrey JAFFEUX 34f4d51238
FIX: prevents drawer error when resizing core composer (#19195)
The drawer is registering events which are expecting the drawer to always be present which was not the case anymore. A previous refactor also changed this component to be tagless.
2022-11-25 18:33:54 +01:00
Joffrey JAFFEUX 9ade68233c
UX: alters chat icon behavior on drawer and mobile (#19192)
Refines the behavior of clicking the chat icon in mobile and when in drawer mode as follows: If chat is open, clicking the icon takes you to the index.
2022-11-25 15:12:32 +01:00
Joffrey JAFFEUX 84c1cc70d6
REFACTOR: naming and state refactor (#19187)
- better handling of drawer state using chat state manager
- removes various float and topic occurrences to use drawer
- ensures user can chat before doing a lot of chat setup
- fixes a bug which was creating presence errors in tests
- removes dead code
2022-11-25 14:15:38 +01:00
Joffrey JAFFEUX e9863b145c
UX: ensures browse view input is focused on page load (#19137)
No test as I don't think it's worth the complexity of a test.
2022-11-22 08:57:17 +01:00
Joffrey JAFFEUX d127d2acdf
FIX: allows to change sound when no sound was ever set (#19136)
It fixes a bug which was only allowing users with a sound to change it. Users with `none` could not change it again after a full page reset.
2022-11-22 08:57:06 +01:00
Kris bc61629d0f
A11Y: improved titles for chat in the sidebar (#19134) 2022-11-22 09:24:39 +08:00
Joffrey JAFFEUX 5573257158
FIX: enable_auto_join_users was used in create channel (#19128)
7e39a21de1
broke the explanation of the check box on `create-channel` view.

Actions:
- uses core yes_value/no_value
- re-add the correct translation for `enable_auto_join_users`
- removes `disable_auto_join_users` which is not used anymore
2022-11-21 14:28:11 +01:00
Joffrey JAFFEUX 3f24a5e9e2
FIX: better chat-message-actions position (#19111)
- prevents menu to hide underlying text
- prevents `chat-message-actions` to close when hovering dropdown of 3
dots button as mouse would hover an other message due to the small space
between `chat-message-actions` menu and the dropdown of the 3 dots
button

<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in
JavaScript). If your code does not include test coverage, please include
an explanation of why it was omitted. -->
2022-11-21 09:10:52 +01:00
Martin Brennan d3f02a1270
FEATURE: Generic hashtag autocomplete lookup and markdown cooking (#18937)
This commit fleshes out and adds functionality for the new `#hashtag` search and
lookup system, still hidden behind the `enable_experimental_hashtag_autocomplete`
feature flag.

**Serverside**

We have two plugin API registration methods that are used to define data sources
(`register_hashtag_data_source`) and hashtag result type priorities depending on
the context (`register_hashtag_type_in_context`). Reading the comments in plugin.rb
should make it clear what these are doing. Reading the `HashtagAutocompleteService`
in full will likely help a lot as well.

Each data source is responsible for providing its own **lookup** and **search**
method that returns hashtag results based on the arguments provided. For example,
the category hashtag data source has to take into account parent categories and
how they relate, and each data source has to define their own icon to use for the
hashtag, and so on.

The `Site` serializer has two new attributes that source data from `HashtagAutocompleteService`.
There is `hashtag_icons` that is just a simple array of all the different icons that
can be used for allowlisting in our markdown pipeline, and there is `hashtag_context_configurations`
that is used to store the type priority orders for each registered context.

When sending emails, we cannot render the SVG icons for hashtags, so
we need to change the HTML hashtags to the normal `#hashtag` text.

**Markdown**

The `hashtag-autocomplete.js` file is where I have added the new `hashtag-autocomplete`
markdown rule, and like all of our rules this is used to cook the raw text on both the clientside
and on the serverside using MiniRacer. Only on the server side do we actually reach out to
the database with the `hashtagLookup` function, on the clientside we just render a plainer
version of the hashtag HTML. Only in the composer preview do we do further lookups based
on this.

This rule is the first one (that I can find) that uses the `currentUser` based on a passed
in `user_id` for guardian checks in markdown rendering code. This is the `last_editor_id`
for both the post and chat message. In some cases we need to cook without a user present,
so the `Discourse.system_user` is used in this case.

**Chat Channels**

This also contains the changes required for chat so that chat channels can be used
as a data source for hashtag searches and lookups. This data source will only be
used when `enable_experimental_hashtag_autocomplete` is `true`, so we don't have
to worry about channel results suddenly turning up.

------

**Known Rough Edges**

- Onebox excerpts will not render the icon svg/use tags, I plan to address that in a follow up PR
- Selecting a hashtag + pressing the Quote button will result in weird behaviour, I plan to address that in a follow up PR
- Mixed hashtag contexts for hashtags without a type suffix will not work correctly, e.g. #ux which is both a category and a channel slug will resolve to a category when used inside a post or within a [chat] transcript in that post. Users can get around this manually by adding the correct suffix, for example ::channel. We may get to this at some point in future
- Icons will not show for the hashtags in emails since SVG support is so terrible in email (this is not likely to be resolved, but still noting for posterity)
- Additional refinements and review fixes wil
2022-11-21 08:37:06 +10:00
Joffrey JAFFEUX 26fadbdece
FIX: hides user card button when current user can't DM (#19093) 2022-11-17 23:44:05 +01:00
Loïc Guitaut 3fd0423b1b FEATURE: Stop hiding “allow archiving channels” setting 2022-11-17 11:03:42 +01:00
chapoi 7e39a21de1
UX: redesign of chat settings + add chat retention info (#19017)
* UX: redesign of chat settings
2022-11-16 11:10:42 +01:00
Joffrey JAFFEUX df7730d938
UX: improves arrow support in chat emoji picker (#19038) 2022-11-16 08:52:48 +01:00
Joffrey JAFFEUX 8f5936871c
FIX: prevents arrow keys to bubble into parents components (#19000)
ember-template-link doesn’t recommend keydown, but listening on keyup won't work to prevent the scroll of the container
2022-11-14 16:53:22 +01:00
Joffrey JAFFEUX c6949a26c5
FIX: only applies scroll position to full page (#19011)
No tests as:
- scroll position is not always supe reliable
- this should all be replaced by sidebar and is not supposed to change much
2022-11-14 13:21:27 +01:00
Krzysztof Kotlarek 3d5753c42b
FIX: Allow sidebar links to register didInsert actions (#19010)
Previously `this.chatService.appEvents.on(
"chat:user-tracking-state-changed"...)` was registered on constructor and disabled on `willDestroy`. Constructor is evaluated only once, so when the section was collapsed and collapsed then the events were not observed anymore.

didInsert allows evaluating code each time a component is rendered.
2022-11-14 10:36:46 +01:00
Joffrey JAFFEUX 895898b363
FIX: correctly opens drawer to message id when given (#18994) 2022-11-14 08:16:09 +01:00
Joffrey JAFFEUX 27c15bfd53
FIX: ensures composer is focused after edit (#18999)
- afterRender is not needed as it's already done in the `chat:focus-composer` event
- removes `focusComposer` function which is duplicating logic
2022-11-14 08:15:20 +01:00
Joffrey JAFFEUX 1a1d1424ed
FIX: only checks for full page instead of preference (#18998)
Checking for preference is unsure when in standalone chat app (eg: electron app), this is much more resilient and simple.
2022-11-14 08:15:02 +01:00
Joffrey JAFFEUX 88ede43ec5
FIX: correctly highlights active channel (#18991)
Prior to this change, only hovering the row would highlight it.
2022-11-11 22:32:06 +01:00
Joffrey JAFFEUX c8beefc1ee
FIX: reimplements chat audio into a service (#18983)
This implementation attempts to be more resilient to background tab.

Notes:
- adds support for immediate arg in @debounce decorators
- fixes a bug in discourseDebounce which was not supporting immediate arg in tests
- chat-audio-manager has no tests as audio requires real user interaction and is hard to test reliably
2022-11-11 13:11:41 +01:00
Joffrey JAFFEUX 66130dc8c1
REFACTOR: handles every chat resource as an URL (#18961)
- Note this is also tweaking the UI a little bit as we are now using links/buttons in the header as needed
- It disables the find ideal channel in drawer mode, if loading `/chat` in drawer mode it will either reopen at the last position or just stay on index
2022-11-11 06:39:15 +01:00
Joffrey JAFFEUX 07e1b0591f
REFACTOR: chat-msgactions (#18969)
- s/chat-msg-actions/chat-message-actions
- s/chat-msgactions-hover/chat-message-actions-container
- creates dedicated css files for this component
- removes useless code
- removes grayscale
2022-11-10 15:08:14 +01:00
Joffrey JAFFEUX c0a4823203
UX: tweaks to msg actions menu (#18966)
- allows to scroll while hovering the menu
- correctly changes message background color while hovering menu
- prevents a bug where it would sometimes close the menu while moving from menu to the 3 dots expanded dropdown. This was caused by the gap between header/body of the 3 dots dropdown, which would sometimes allow to create a mouseover event on a possible different underlying message
- removes recent/favorite reactions on drawer mode
- grayscale reactions until hover
- boxshadow on msgactions container
- removes useless code
2022-11-10 07:42:37 +01:00
Keegan George 3d376c71b6
A11Y: Improve accessibility for saved status message (#18950)
Toggling channel settings shows a status message when saved. This status message is not accessible to screen readers. This commit ensures that the status message is made accessible.
2022-11-09 10:12:35 -08:00
Martin Brennan c6764d8c74
FIX: Automatically generate category channel slugs (#18879)
This commit automatically ensures that category channels
have slugs when they are created or updated based on the
channel name, category name, or existing slug. The behaviour
has been copied from the Category model.

We also include a backfill here with a simplified version
of Slug.for with deduplication to fill the slugs for already
created Category chat channels.

The channel slug is also now used for chat notifications,
and for the UI and navigation for chat. `slugifyChannel`
is still used, but now does the following fallback:

* Uses channel.slug if it is present
* Uses channel.escapedTitle if it is present
* Uses channel.title if it is present

In future we may want to remove this altogether
and always rely on the slug being present, but this
is currently not possible because we are not generating
slugs for DM channels at this point.
2022-11-09 10:28:31 +10:00
Joffrey JAFFEUX 4e6909cc5a
FIX: uses i18n for saved text (#18949) 2022-11-09 00:15:57 +01:00
Joffrey JAFFEUX 074aa5eb5e
FIX: handles starting draft dm from sidebar (#18946) 2022-11-08 23:58:11 +01:00
Joffrey JAFFEUX 21570410ab
FIX: makes sidebar links respect drawer mode (#18918)
Clicking a link of the sidebar will now open the drawer and load the correct channel.

This solution should correctly solve these cases:

closing drawer, clicking sidebar channel, should open the drawer on correct channel
visiting /chat then visiting / and clicking sidebar channel, should open full page chat on correct channel
2022-11-08 16:23:13 +01:00
Joffrey JAFFEUX 0a02a5d05a
FIX: follow up to #7fca078 (#18915)
- prevents triggering chat:open-channel two times
- builds a correct URL for home page
2022-11-07 19:31:08 +01:00
Joffrey JAFFEUX 7fca07821b
FIX: simplfies previous route handling (#18895)
This commits makes sure we correctly wait for the end of the transition to reopen the drawer on the correct channel/view. Also fixes a bug when previous URL was `/` and causing a double transition.
2022-11-07 14:48:18 +01:00
Joffrey JAFFEUX a51e5e1987
DEV: separates preferred-chat-mode service (#18883)
Also adds end to end system tests to ensure navigation scenarios are working correctly. This separation will make it easier to implement state in/out from chat.
2022-11-07 09:04:43 +01:00
Joffrey JAFFEUX 49a0129b0d
FIX: prevents chat to enter in endless loop when getting 404 (#18867)
Doing DOM operations in finally would cause them to happen even when the request was a failure. Consequence of these DOM operations would be new request, which would also end up in a 404, and so on.

This commit simply moves the DOM operations in the then block where it should be safe to make.
2022-11-03 19:52:44 +01:00
Loïc Guitaut abcaa1a961 DEV: Rename direct message related models
This is a followup of the previous refactor where we created two new
models to handle all the dedicated logic that was present in the
`ChatChannel` model.

For the sake of consistency, `DMChannel` has been renamed to
`DirectMessageChannel` and the previous `DirectMessageChannel` model is
now named `DirectMessage`. This should help reasoning about direct
messages.
2022-11-03 14:39:23 +01:00
Keegan George 0028149ed4
UX: Add back button in chat browse screen on mobile (#18849) 2022-11-03 09:06:30 +01:00
Alan Guo Xiang Tan d446ad3290
UX: Muted style for entire chat section link when muted (#18852) 2022-11-03 08:37:39 +09:00
Keegan George 2e984f2eca
UX: Increase padding of back button in chat draft screen (#18848)
To increase hit target size for easier press on mobile devices
2022-11-02 21:28:41 +01:00
Roman Rizzi 0a5f548635
DEV: Move `discourse-chat` to the core repo. (#18776)
As part of this move, we are also renaming `discourse-chat` to `chat`.
2022-11-02 10:41:30 -03:00