Commit Graph

2366 Commits

Author SHA1 Message Date
Martin Brennan ae74d5b32e
FIX: Chat deleted last read message and tracking state issues (#21762)
#### FIX: Do not use client lastReadMessageId when fetching channel messages

We had an issue where the following happened:

1. User opened channel and saw the last message, and we set the
   lastReadMessageId on the server and the client
2. User navigated to another channel
3. Another user deleted the message in the original channel
4. The first user navigated back to the original channel before
   the MessageBus event for the deleted message arrived, and got
   a 404 error because we were sending the deleted lastReadMessageId as
   target_message_id to the channel controller.

Instead of this which is a bit flaky and is hard to cover all
the issues for, instead we can pass a fetch_from_last_read boolean
param to the channels controller, and just get the user's
last_read_message_id straight from the database to use for the
target_message_id. This gets rid of any sources of race conditions
or lack of updates from MessageBus.

#### FIX: Include missing memberships for thread tracking publish

When we publish the channel/message tracking state for a
user and that message was a thread reply the publisher
was erroring because we were not telling Chat::TrackingStateReportQuery
to return missing memberships (which have zeroed out unread counts)
as well, which is what we do for the channel tracking state here.
Also just make sure that the TrackingStateReport does not error
when passed an ID it doesn't have data for.
2023-05-26 10:44:27 +02:00
Joffrey JAFFEUX 8d2ae1e4a6
DEV: waits for transition in move message spec (#21763)
This flakey has been very visible by the new headless chrome. The problem was that after moving a message we automatically redirect to the channel where the message has been moved to. However, we were not explicitly waiting for this transition and a result it could happen that we attempt to check the presence of the message on the channel page before the redirect actually happened.

The various naming changes are due to an early mistake we made in chat specs to use `chat` as the variable name for the page object which prevents to use the automatic path `chat.channel_path(...)`.

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
2023-05-26 10:04:37 +02:00
Joffrey JAFFEUX 0645f3628c
UI: minor spacing adjustment in message details (#21761) 2023-05-26 09:16:27 +02:00
Andrei Prigorshnev f0dfe56870
DEV: extract more logic into ParsedMentions class (#21729)
This doesn't change any behavior, only moves code around.
2023-05-25 15:41:22 +04:00
Martin Brennan c3779a371f
FIX: Serialize thread membership for user (#21743)
This commit follows up b6c5a2da08
by serializing the user's thread memberships in these cases:

1. When we do the initial channel fetch with messages, we get
   all threads and all the user's thread memberships for those
   messages.
2. When the thread list is fetched, we get all the user's memberships
   in that list.
3. When the single thread is fetched, either from opening it from
   the list, an OM indicator, or just from doing .find() on the
   manager when a new MessageBus message comes in

This will let us track the lastReadMessageId on the client, and
will also let us fix an issue where the unread indicator in the
channel header was incrementing for every thread that got a
new message, regardless of whether the user was a member.
2023-05-25 12:54:50 +02:00
Loïc Guitaut 0733dda1cb DEV: Add policy objects to services
This patch introduces policy objects to chat services. It allows putting
more complex logic in a dedicated class, which will make services
thinner. It also allows providing a reason why the policy failed.

Some change has been made to the service runner too to use more easily
these new policy objects: when matching a failing policy (or any failing
step actually), the result object is now provided to the block. This
way, instead of having to access the reason why the policy failed by
doing `result["result.policy.policy_name"].reason` inside the block,
this one can be simply written like this:
```ruby
  on_failed_policy(:policy_name) { |policy| policy.reason }
```
2023-05-25 12:34:00 +02:00
Jarek Radosz 22a6ae7e32
DEV: Remove `renderTemplate` from the styleguide (#21660)
Adds plugin API:

```js
import fidget from "../components/styleguide/molecules/fidget";

api.addStyleguideSection({
  component: fidget,
  id: "fidget",
  category: "molecules",
  priority: 0,
});
```

Removes notes. You can always add `<p class="styleguide-note">` to section components to annotate them.
2023-05-25 11:22:36 +02:00
Martin Brennan b6c5a2da08
FEATURE: Initial chat thread unread indicators (#21694)
This commit adds the thread index and individual thread
in the index list unread indicators, and wires up the message
bus events to mark the threads as read/unread when:

1. People send a new message in the thread
2. The user marks a thread as read

There are several hacky parts and TODOs to cover before
this is more functional:

1. We need to flesh out the thread scrolling and message
   visibility behaviour. Currently if you scroll to the end
   of the thread it will just mark the whole thread read
   unconditionally.
2. We need to send down the thread current user membership
   along with the last read message ID to the client and
   update that with read state.
3. We need to handle the sidebar unread dot for when threads
   are unread in the channel and clear it based on when the
   channel was last viewed.
4. We need to show some indicator of thread unreads on the
   thread indicators on original messages.
5. UI improvements to make the experience nicer and more
   like the actual design rather than just placeholders.

But, the basic premise around incrementing/decrementing the
thread overview count and showing which thread is unread
in the list is working as intended.
2023-05-25 09:56:19 +02:00
Joffrey JAFFEUX eae47d82e2
FEATURE: Apply hashtag styles to autocomplete (#21731)
This commit uses improvements done in 0b3cf83 to apply these styles to the autocomplete in composer.
2023-05-25 09:38:12 +02:00
Joffrey JAFFEUX 398eaf0429
FIX: prevents saving draft in incorrect channel (#21741)
This commit regroups 3 changes
- serializes channel ID and json draft when calling the debouncer instead of inside the debounced function, it seems very unlikely to happen, but in a case where the debouncing wouldn't be canceled and the new message not set yet, we could save the draft on an invalid channel
- cancel persist draft handler when changing channel
- ensures we exit early when channel is not set
2023-05-25 09:29:31 +02:00
Joffrey JAFFEUX 082921c4c8
FIX: correctly nullifies active message (#21739)
Very fast or specific mouse moves could allow to leave a message actions menu without reseting the active message. This commit should ensure we correctly catch this event.

No test as it's hard and not reliable to reproduce these in a test.
2023-05-25 09:28:46 +02:00
Joffrey JAFFEUX f3f841a018
DEV: implements initial messages component (#21727)
This should also make `message_notifications_with_sidebar_spec.rb` more resilient as we are now checking for `is-persisted` class instead of checking for the absence of `is-staged`.
2023-05-24 19:28:54 +02:00
Andrei Prigorshnev d6d5eae16f
DEV: temporarily skip tests tha fails on the build machine (#21725) 2023-05-24 18:49:00 +04:00
Joffrey JAFFEUX 4de1d3952b
FIX: improves draft for channels (#21724)
This commit attempts to correctly change draft when the channel changes. It moves responsibility to the composer instead of the channel.

A new service `chatDraftsManager` is being introduced here to allow finer control and pave the way for future thread draft support.

These changes also now allow an editing message to be stored as a draft.
2023-05-24 15:36:46 +02:00
Andrei Prigorshnev d4a5b79592
FEATURE: Add user status to inline mentions in chat (#20564)
This PR adds status to mentions in chat and makes those mentions receive live updates.

There are known unfinished part in this implementation: when posting a message, status on mentions on that message appears immediately, but only if a user used autocomplete when typing the message. If user copy and paste a message with mentions into chat composer, those mentions won't have user status on them.

PRs with fixes for both problems are following soon.

Preparations for this PR that were made previously include:
- DEV: correct a relationship – a chat message may have several mentions 0dcfd7ddec
- DEV: extract the logic for extracting and expanding mentions from ChatNotifier 75b81b6854
- DEV: Always create chat mention records fa543cda06
- DEV: better split create_notification! and send_notifications logic e292c45924
- DEV: more tests for mentions when updating chat messages e7292e1682
- DEV: extract updating status on mentions into a lib function e49d338c21
- DEV: Create and update chat message mentions earlier 35a414bb38
- DEV: Create a chat_mention record when self mentioning 2703f2311a
- DEV: When deleting a chat message, do not delete mention records f4fde4e49b
2023-05-24 16:55:20 +04:00
Jan Cernik 436b68a581
FIX: Do not preview chat channels to read-only users (#21700)
We want to simplify this case as it contains a lot of rabbit holes.
2023-05-24 14:05:20 +02:00
Martin Brennan 2b4dc97551
FIX: Do not error if admin/owner checks target message (#21721)
In the ChannelViewBuilder, we introduced a check to see if
the target message exists, which errors if the message has
been trashed. However if the user is the creator of the message
or admin then they are able to see trashed messages, so
we need to take this into account.
2023-05-24 12:01:41 +02:00
Martin Brennan 8076a84ff0
DEV: Reinstate Chat::MessageCreator skipped thread specs (#21718)
Followup to 7f85624a01

Fixes the specs that were skipped and reinstates them
2023-05-24 10:59:11 +02:00
Martin Brennan 177d8dfcd1
FIX: Improve chat membership update on deleted message (#21716)
Followup to c908eeacc9

Instead of using the latest message ID in the channel, which
could cause issues if you have an earlier last read message ID
that matches the deleted one, instead we use the first non-deleted
message that comes before the deleted message by ID.
2023-05-24 10:31:15 +02:00
Kris 5dd89e0b70
UX: iPad footer nav now included in header offset (#21699) 2023-05-23 17:49:19 -04:00
Joffrey JAFFEUX 8feee8149f
DEV: attempts to increase wait for a flakey spec (#21705) 2023-05-23 22:43:50 +02:00
Discourse Translator Bot 0d7a742bb9
Update translations (#21702) 2023-05-23 21:23:44 +02:00
Joffrey JAFFEUX 68364461f8
FIX: ensure sidepanel size is correctly applied when showing (#21701)
We were not correctly setting the widthStyle on insert.

Note this commit also changes throttling from 24ms to 50ms. 24ms was probably overkill.
2023-05-23 20:13:58 +02:00
Martin Brennan c908eeacc9
FIX: Update client lastReadMessageId on trashed message (#21697)
Followup ae3231e140, when a
message is trashed we already update the lastReadMessageId of
all users in the channel to the latest non-deleted message on
the server side. However we didn't propagate this to the client,
so in some cases when we did the following:

1. Delete the last message in the channel
2. Switch to another channel
3. Switch back to the original

We would get a 404 error from the target message ID being looked
up still being the old lastReadMessageId (now deleted) for the
user's channel membership.

All we need to do is send the last not-deleted message ID for
the channel (or thread) to all the member users.
2023-05-23 18:32:19 +02:00
Joffrey JAFFEUX bce56d843c
FIX: keeps panel size when changing content (#21698)
Before this commit the following actions would have shown the issue:
- visit a thread
- changes the width of the side panel
- open threads list
- the size has reverted to previous state

This was caused by the width change to not correctly be tracked.
2023-05-23 18:29:12 +02:00
Joffrey JAFFEUX c543a3207d
DEV: removes very frequent flakey spec (#21696) 2023-05-23 17:45:10 +02:00
Joffrey JAFFEUX 2a7dae51fa
DEV: attempts to make deleted spec not flakey (#21695)
It easier to check for presence in this case that to check for something not present, as depending on performance of the machine running the test this could take sometime to be changed and the test would fail.
2023-05-23 17:13:12 +02:00
Joffrey JAFFEUX 0764dc3452
FIX: cancel fetching messages after channel change (#21689)
This issue was especially visible in tests. the `@debounce(100)` was not cancelled when changing channel which was causing 404s as we were trying to load messages on a channel which was deleted as the channel has been destroyed at the end of the test.

This is still not a perfect solution, as we can only cancel the start of `fetchMessages`, but we can't cancel the actual `chatApi.channel` request which result can potentially happens after channel changed, which we try to mitigate with various checks on to ensure visible channel == loaded messages channel.

This commit also tries to make handler naming and cancelling more consistent.

<!-- 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. -->
2023-05-23 16:01:47 +02:00
Martin Brennan 6dc05dc535
DEV: Fix chat pagination spec (#21693) 2023-05-23 12:47:43 +02:00
Martin Brennan 3fed1abf2f
FIX: Page size check for thread messages (#21692) 2023-05-23 11:59:19 +02:00
Martin Brennan dad6b61807
DEV: Bump thread page size to 100 (#21691)
We don't have proper pagination yet so this
should help us in the interim.
2023-05-23 10:43:39 +02:00
Joffrey JAFFEUX b8bd3b07ef
DEV: regroups composer button code (#21690)
This commit makes it easier to ensure each button have a similar behavior: hover, disabled, focus...

It also removes some dead code (__inline-button) and fixes a bug where the emoji button didnt have the right un-focused color (it was more visible than it should.
2023-05-23 10:12:03 +02:00
Martin Brennan 0b3cf83e3c
FIX: Do not cook icon with hashtags (#21676)
This commit makes some fundamental changes to how hashtag cooking and
icon generation works in the new experimental hashtag autocomplete mode.
Previously we cooked the appropriate SVG icon with the cooked hashtag,
though this has proved inflexible especially for theming purposes.

Instead, we now cook a data-ID attribute with the hashtag and add a new
span as an icon placeholder. This is replaced on the client side with an
icon (or a square span in the case of categories) on the client side via
the decorateCooked API for posts and chat messages.

This client side logic uses the generated hashtag, category, and channel
CSS classes added in a previous commit.

This is missing changes to the sidebar to use the new generated CSS
classes and also colors and the split square for categories in the
hashtag autocomplete menu -- I will tackle this in a separate PR so it
is clearer.
2023-05-23 09:33:55 +02:00
Joffrey JAFFEUX c3a3ede8cf
FIX: correct replying indicator padding (#21679) 2023-05-22 17:55:31 +02:00
Joffrey JAFFEUX bdfd80bfe0
UI: chat composer step 2 (#21641)
- few improved alignments
- displays emoji picker button inline on desktop
- keeps composer focused when focusing dropdown button
- align buttons to bottom when increasing height of textarea
- max-height of textarea is now linked to the height of the screen

Co-authored-by: chapoi <charlie@discourse.org>
2023-05-22 17:00:50 +02:00
Martin Brennan 5cce829901
DEV: Chat API channel#show changes for threading (#21632)
This commit moves message lookup and querying to the
/chat/api/channel/:id endpoint and adds the ability
to query the tracking state overview for threads as well
as the threads and thread tracking state for any thread
original messages found.

This will allow us to get an initial overview of thread
tracking for a user when they first enter a channel, rather
than pre-emptively loading N threads and tracking state
for those across all channels on the current user serializer,
which would be expensive.

This initial overview will be used in subsequent PRs to
flesh out the thread unread indicators in the UI.

This also moves many chunks of code that were in services
to reusable Query classes, since use of services inside
services is discouraged.
2023-05-22 13:59:46 +02:00
Jarek Radosz 7f85624a01
DEV: Fix plugin:spec task return code (#21661)
Regressed in eec10efc3d. It means that backend plugin spec failures in CI were not failing the spec suite.

Fixes recent regressions and skips two of them - to be handled next week.

---------

Co-authored-by: Andrei Prigorshnev <a.prigorshnev@gmail.com>
2023-05-19 16:17:02 +02:00
chapoi 4f8dbe345f
UX: add indicator for msg from currentUser (#21657)
* UX: add indicator for msg from currentUser

* move up a level
2023-05-19 11:33:56 +02:00
Jarek Radosz f2339d2d5b
DEV: Fix random typos (#21638) 2023-05-18 15:34:46 +02:00
chapoi 7444ab006d
UX: General chat composer tweaks (#21639)
- prevent hover on disabled state
- more contrast between focus and not focus for send button
2023-05-18 15:15:10 +02:00
Joffrey JAFFEUX ed123c7cec
FIX: adds missing margin on desktop draft message (#21637) 2023-05-18 14:40:37 +02:00
Joffrey JAFFEUX c1d3a6a205
FIX: ensures message has been added before scroll (#21636)
Wrap scroll to bottom inside a next block to ensure the message has correctly been added to the array before actually attempt to scroll.

This commit also removes an unnecessary line which was essentially adding the message two times with no real consequences as we are uniq on ID.
2023-05-18 13:50:09 +02:00
chapoi ab4e2bed84
UX: minor fix with new composer and reply/edit (#21634) 2023-05-18 12:04:14 +02:00
Andrei Prigorshnev 20a7192b4e
DEV: Avoid infinite calling of computeDatesSeparators() (#21616) 2023-05-18 09:53:40 +02:00
Penar Musaraj a25bb81a64
DEV: Improve manual color scheme toggle in styleguide (#21629) 2023-05-18 07:31:20 +02:00
Joffrey JAFFEUX 4c4401b726
FIX: various fixes to chat styleguide (#21617)
- uses current user as user for fabricators, allows for correct avatar image and presence indicator
- uses a non existing channel ID to avoid setting a draft of an existing channel
- attempts to make color toggle more reliable
2023-05-17 20:03:19 +02:00
Joffrey JAFFEUX 0c1efecddd
FIX: more resilient bottom of message check (#21613)
1.0 lenience might not be enough in rare cases and there are no real consequences to slightly increase it.
2023-05-17 18:05:18 +02:00
Joffrey JAFFEUX 44d28cd778
FIX: ensures replying indicator has limited height (#21614) 2023-05-17 18:03:15 +02:00
Joffrey JAFFEUX 60c67afba4
DEV: various improvements to devex on chat (#21612)
- Improves styleguide support
- Adds toggle color scheme to styleguide
- Adds properties mutators to styleguide
- Attempts to quit a session as soon as done with it in system specs, this should at least free resources faster
- Refactors fabricators to simplify them
- Adds more fabricators (uploads for example)
- Starts implementing components pattern in system specs
- Uses Chat::Message creator to create messages in system specs, this should help to have more real specs as the side effects should now happen
2023-05-17 17:49:52 +02:00
Joffrey JAFFEUX df2614c0fb
FIX: ensures chat composer docks to topic composer (#21610) 2023-05-17 11:16:03 +02:00
chapoi 4c476b42b0
UX: chat composer styling on focus (#21603) 2023-05-17 07:10:02 +02:00
Joffrey JAFFEUX 928fab1c4e
FIX: compensate for lack of replying indicator on draft (#21597)
As we don't have the spacing generated by the replying indicator, we need to manually add spacing.
2023-05-16 22:32:07 +02:00
Martin Brennan 009006893e
FIX: Sync channel tracking state properly on presence change (#21596)
Followup from 9953a6edd9,
which broke an issue fixed in e8d6277062.

In the refactor we did not update the place where we resync
channel tracking based on onPresenceChange to use the new
tracking object we added to the serializer, and to directly
update channel.tracking
2023-05-16 21:37:51 +02:00
Joffrey JAFFEUX 0881186bfd
UI: removes thread margins (#21595) 2023-05-16 21:28:25 +02:00
Joffrey JAFFEUX 2f73316104
FIX: followups to composer notch adjustments (#21592)
We had safe-area-inset-bottom still set at a wrong place which was causing issues but was also useful to some cases. This commit removes it and ensures the affected cases are corrected.
2023-05-16 20:05:56 +02:00
Discourse Translator Bot 791630f08b
Update translations (#21583) 2023-05-16 19:40:01 +02:00
Joffrey JAFFEUX 4bfd1fd998
FIX: allows notch to have composer bg color (#21589) 2023-05-16 18:46:14 +02:00
Joffrey JAFFEUX f45d1e6791
UX: implements new composer design (#21588)
This is only the first steps of a redesign

- redesigns the buttons to have a larger hitzone
- generally bigger composer
- clicking near textarea focuses the input
- relies on the fact that safe-area-inset-bottom is set globally and doesn’t need to be set in sub components
2023-05-16 17:17:12 +02:00
Joffrey JAFFEUX 230a71b264
FIX: show scrollbars under firefox in chat (#21587) 2023-05-16 16:44:15 +02:00
Penar Musaraj 56422ca8b8
FIX: Don't show duplicates in styleguide (#21582) 2023-05-16 09:27:15 -04:00
Martin Brennan 9953a6edd9
DEV: Rearchitect chat tracking state (#21550)
This moves chat tracking state calculation for channels
and threads into a central Chat::TrackingStateManager service, that
serves a similar purpose to the TopicTrackingState model
in core.

This service calls down to these query classes:

* ThreadUnreadsQuery
* ChannelUnreadsQuery

To get the unread_count and mention_count for the appropriate
channels and threads.

As well as this, this commit refactors the client-side chat
tracking state.

Now, there is a central ChatTrackingStateManager Ember Service
so all tracking is accessible and can be counted from one place,
which can also initialize tracking from an initial payload.

The actual tracking counts are now maintained in a ChatTrackingState
class that is initialized on the `.tracking` property of both channel and
thread objects.

This removes the attributes on UserChatChannelMembership and decoration
of said membership from ChannelFetcher, preferring instead to have an additional
object for tracking in the JSON.
2023-05-16 14:51:13 +02:00
Martin Brennan a2b12b6ace
FIX: Drawer styles for chat thread icon (#21577)
The spacing was not correct for this icon
in the drawer.
2023-05-16 12:49:19 +02:00
chapoi 7032733f10
FIX: Add new chat threads icon and move thread list button to right (#21575)
* DEV: add new thread icon

* FIX: Use new thread icon, fix typo in SVG

UX: move the thread list icon to the right of
the collapse button

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
2023-05-16 11:48:01 +02:00
Joffrey JAFFEUX a3522a5937
FIX: chat height fixes (#21561)
- Correctly resize when sending a message on android
- Do not blur active element
- Update direct message creator height following changes
2023-05-15 22:00:03 +02:00
Joffrey JAFFEUX 94b95266ca
FIX: hides global notice on chat (#21557)
It's not necessary and we already hide create-topics-notice and bootstrap mode, and it's also annoying to get correct chat's height.
2023-05-15 17:08:05 +02:00
Joffrey JAFFEUX 4b15ba405c
FIX: moves chat height computation to a mixin (#21555)
This commit also removes safe-area-inset-bottom when keyboard is displayed to avoid having a taller than needed space between composer and replying indicator.
2023-05-15 15:53:18 +02:00
Joffrey JAFFEUX 660a40ca06
FIX: various fixes following channel height changes (#21553)
- apply height on threads list
- apply height on thread
- correctly applies env(safe-area-inset-bottom)
2023-05-15 14:39:11 +02:00
Joffrey JAFFEUX 5ce0697348
FIX: limits max height to viewport on channel only (#21539)
Before this commit chat was applying a fixed height on everything under the `/chat` route. It's only really needed on the channel page with the composer at the bottom of the page.

This commits makes the following changes:
- moves height limitation from `#main-outlet-wrapper` to `.chat-channel`
- makes browse channel page and members list page full height and rely on main document scrollbar
- adds height computation for draft header and direct message creator block to ensure the height is correct when creating a draft channel
- makes chat index full height to rely on the browser scrollbar. As a result the <kbd> + </kbd> button used on mobile to create a direct message as been moved out of `<ChannelsList>` into the chat index template
- sidebar height was relying on chat setting a max height, as a result the height computation of sidebar has been changed to work correctly, especially with an opened keyboard on mobile or ipad
2023-05-15 11:46:33 +02:00
Joffrey JAFFEUX 580f60d61d
Revert "DEV: attempts to fix flakey spec (#21547)" (#21549)
This reverts commit 64971e5972.
2023-05-15 08:18:18 +02:00
Joffrey JAFFEUX c8eb1a275c
UX: opens side panel early to avoid jitter (#21516)
Hard to write a test for this behavior, this is a micro optimisation which doesn’t change the behavior but only makes it smoother by happening right before async request.
2023-05-15 08:14:50 +02:00
chapoi 74f01b8cbd
UX: hide settings btn when disabled
Also sets lighter border on hover
2023-05-15 07:53:30 +02:00
Joffrey JAFFEUX 64971e5972
DEV: attempts to fix flakey spec (#21547)
The failure screenshot shows the message is on screen while the error is:

```
     Failure/Error: example.run
       expected to find text "My favorite message" in "Community\nEverything\nMy Posts\nMore\nMessages\nInbox\nChannels\nPolitics 1\nPersonal chat\nPolitics 1". (However, it was found 1 time including non-visible text.)
```

I expect the arrow element might e slightly hiding the link, but not 100% sure of this.
2023-05-15 07:52:02 +02:00
Daniel Waterworth 53d99d1a26
DEV: Skip flaky tests (#21534) 2023-05-15 07:51:25 +02:00
Joffrey JAFFEUX 3f2c16a8d7
FIX: do not set VH while zooming (#21538)
This was an optimisation I mistakenly removed from 4cfa78c3f3
2023-05-13 17:39:24 +02:00
Joffrey JAFFEUX 4cfa78c3f3
FIX: always listen on window resize (#21536)
When using `navigator.virtualKeyboard.overlaysContent = false` we can rely on using only the resize event. Also attempts to no over trigger `setProperty` when value didn't change.
2023-05-13 15:39:46 +02:00
Andrei Prigorshnev b85d057df4
FIX: ensures `all_mentioned_user_ids` is not used as identifier (#21491)
A follow-up to 54b2a85b. That commit didn't fix the issue because the to_notify hash that we return from the notify_edit method isn't used anywhere apart from tests (that's confusing, we're going to fix that soon).
2023-05-12 17:47:48 +04:00
Martin Brennan c1cde16966
FIX: Thread reply indicator overflow (#21529)
In some cases the thread reply count indicator
(e.g. 433 replies) would wrap to the next line.
2023-05-12 15:46:22 +02:00
Jarek Radosz d8e5426bba
FIX: Incorrect `PLUGIN_NAME` for "poll" (#21525)
This resulted in `Required plugin 'discourse_poll' not found` warnings in logs
2023-05-12 12:54:14 +02:00
Joffrey JAFFEUX e10b262eb9
DEV: fix flakey spec (#21515)
Similar fix to the one made in aab6fb13a0

Instead of checking last object, check against all modified objects in no specific order.
2023-05-11 23:27:26 +02:00
Joffrey JAFFEUX f20be4b092
FIX: prevents subscribing with an old id (#21509)
This issue was for example possibly causing the last visit indicator to be reset by `sent` messages events.

The following was happening:
- a user (bob) had a last message bus ID of 1 on a channel (id:1) subscription
- bob then go to another channel (id:2), unsubscribing from updates of channel (id:1)
- another user (laura) then send messages to channel (id:1)
- bob goes back to channel (id:1)

At this point we we doing in the same sequence:
- loading channel with messages, getting a new last message bus id
- subscribing to updates using the last known message bus id

Most of the times we were lucky enough for this to work (no events while away, or just got the new id in time...) but it was also very likely to do a double fetch of messages as MessageBus would think we were late.
2023-05-11 22:27:48 +02:00
Joffrey JAFFEUX e905de66ff
FIX: close panel earlier (#21512)
deactivate was happening too late and sometimes after we did reopen for next panel causing the panel to stay effectively closed
2023-05-11 21:15:31 +02:00
Andrei Prigorshnev f4fde4e49b
DEV: When deleting a chat message, do not delete mention records (#21486)
A chat message may be restored later, so we shouldn't be deleting `chat_mentions` records for it.

But we still have to remove notifications (see 082cd139).
2023-05-11 20:05:59 +04:00
Joffrey JAFFEUX 92bb845db2
FIX: messages selection with shift + click (#21506)
This commit fixes the shift+click multi selection in threads. We were not correctly using the manager of the message and would attempt to find messages in the channel instead of the thread.

The `activeThread` was also not correctly set sometimes.

Also adds tests for message selection in threads.
2023-05-11 17:52:53 +02:00
Andrei Prigorshnev 2703f2311a
DEV: Create a chat_mention record when self mentioning (#21438)
In the past, we create a `chat_mention` records only when we wanted to notify a user about a mention. Since we don't send notifications when a user mentioning himself, we didn't create a `chat_mention` records in those cases.

Now we use `chat_mentions` records in other scenarios too, so when a user is mentioning himself we want to:
1. Create a `chat_mention` record for that mention
2. Do not create a notification for that mention
2023-05-11 19:30:26 +04:00
Joffrey JAFFEUX 0c27baef76
FIX: keyboard on android (#21505) 2023-05-11 16:12:48 +02:00
Martin Brennan 26f9ccd8bb
FEATURE: Create and update thread memberships (#21501)
When the user sends a message in a thread, we want to
create a membership for them in the background (default
to notification level of Watching) so we can track whether
they have read the thread.

Then, for now since we don't have granular message reading/
scrolling in the thread panel, we just update the thread
last_read_message_id for the user to the latest reply in the
thread when they open the thread panel. This at least will
mark the thread as read.

In future PRs we want to show the blue dot indicator in various
places in the UI for unread threads which will also require
some MessageBus functionality.

This takes into account the same issue fixed for channels
in ae3231e140
2023-05-11 14:35:26 +02:00
Joffrey JAFFEUX 5b12d23b1d
FIX: rely only on one keyboard computation solution (#21492)
We were combining both solutions which was apparently causing issues from chrome 113 on Android at least.

The commit will now use `geometrychange` (android) only when available and fallback to `visualViewport` otherwise (iOS).
2023-05-11 08:58:29 +02:00
Joffrey JAFFEUX 55c4a550c1
FEATURE: chat-replying indicator for threads (#21485)
This feature adds the replying indicator in threads, it uses the same `/chat-reply/CHANNEL_ID` prefix than the channel composer replying indicator as we don't have specific right on threads ATM (if you can access channel, you can access thread). Thread will however use a presence channel name of the following format: `/chat-reply/CHANNEL_ID/thread/THREAD_ID`

This commit also simplifies the computation of `users` to eventually avoid a race-condition leading to a leak of the indicator in another channel/thread.

<!-- 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. -->
2023-05-11 08:02:04 +02:00
Joffrey JAFFEUX aab6fb13a0
DEV: fix flakey spec in handle_category_udpated (#21488) 2023-05-11 08:01:02 +02:00
Martin Brennan 616885895a
FIX: Chat NotificationLevels extension breaking in prod (#21484)
When setting DISCOURSE_ZEITWERK_EAGER_LOAD=1 to enable
eager loading the previous solution to adding chat_levels
to the core NotificationLevels would break with a module
loading error (c.f. cc2570fce3)

We don't actually _need_ to extend the core class, we can just
make our own for chat, let's do this instead.
2023-05-10 18:46:06 +02:00
Martin Brennan 79812db7d3
DEV: Fix double Chat:: module usage in chat models (#21483) 2023-05-10 17:51:46 +02:00
Martin Brennan 9b95a65dff
DEV: Fix thread excerpt word break (#21482)
Changing from break-all to break-word because otherwise
longer words (not just links) are split into separ
ate lines.
2023-05-10 17:20:02 +02:00
Martin Brennan cc2570fce3
DEV: Create UserChatThreadMembership table and model (#21481)
This will enable us to begin work on user tracking
state for a thread so we can show thread-specific
unreads and mentions indicators. In this case are following
the core notification_level paradigm rather than the solution
UserChatChannelMembership went with, and eventually we
will want to refactor the other table to match this as well.

Co-authored-by: Joffrey JAFFEUX <j.jaffeux@gmail.com>
2023-05-10 17:19:48 +02:00
Joffrey JAFFEUX b713ae166f
FIX: excerpt overflow and children click events (#21473) 2023-05-10 15:07:43 +02:00
Martin Brennan 91c5658e9b
FIX: Handle deleted original message for thread index (#21470)
Since we have channel message retention which deletes
messages, we can end up with cases where the thread
is still around but the message is deleted. We will
handle the cascade delete in a different commit --
for now we will ensure the thread list lookup handles
this case and doesn't error.
2023-05-10 13:58:15 +02:00
Jan Cernik cbbaeb55b5
FIX: Don't autojoin users when they have ready-only permissions (#20213)
After this change, in order to join a chat channel, a user needs to be in a group with at least “Reply” permission for the category. If the user only has “See” permission, they are able to preview the channel, but not join it or send messages. The auto-join function also follows this new restriction.

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
2023-05-10 08:45:13 -03:00
Joffrey JAFFEUX 3727c95f6f
Revert "DEV: Add configurable? helper to Plugin::Instance (#20767)" (#21469)
This reverts commit 3073e5cfb0.
2023-05-10 12:41:55 +02:00
Bianca Nenciu 3073e5cfb0
DEV: Add configurable? helper to Plugin::Instance (#20767)
This can be used to forcibly disable plugins.
2023-05-10 13:16:37 +03:00
Joffrey JAFFEUX c6b43ce68b
FEATURE: Thread list initial UI (#21412)
This commit adds an initial thread list UI. There are several limitations
with this that will be addressed in future PRs:

* There is no MessageBus reactivity, so e.g. if someone edits the original
   message of the thread it will not be reflected in the list. However if
   the thread title is updated the original message indicator will be updated.
* There is no unread functionality for threads in the list, if new messages
   come into the thread there is no indicator in the UI.
* There is no unread indicator on the actual button to open the thread list.
* No pagination.

In saying that, this is the functionality so far:

* We show a list of the 50 threads that the user has most recently participated
   in (i.e. sent a message) for the channel in descending order.
* Each thread we show a rich excerpt, the title, and the user who is the OM creator.
* The title is editable by staff and by the OM creator.
* Thread indicators show a title. We also replace emojis in the titles.
* Thread list works in the drawer/mobile.
2023-05-10 11:42:32 +02:00
Joffrey JAFFEUX 7a84fc3d9d
DEV: more resilient scroll to bottom spec (#21467)
The spec now checks we are in the state we expect to be before clicking bottom button. The bottom button could show while it's still loading and on slow systems cause failures.
2023-05-10 10:54:02 +02:00