Commit Graph

2381 Commits

Author SHA1 Message Date
Joffrey JAFFEUX
9cbbcdef50
FIX: prevents lightbox to close chat on escape (#22003)
No test as this is very much a hack while lightbox is being revamped. We currently have no good/easy way AFAIK to stop event propagation on escape in magnificpopup.
2023-06-08 15:32:35 +02:00
Joffrey JAFFEUX
32dd43e02c
REVERT: makes touchstart passive (#22004)
This is causing issues with scroll, I need to find a different issue for the event propagating as a click.
2023-06-08 15:31:49 +02:00
Joffrey JAFFEUX
57877fd6db
FIX: on iOS PWA prevents touch to click (#22000)
This behavior has been possible for a long time and has been made more in recent commits. On PWA iOS when release the touch after the mobile actions menu has been shown, if the finger was over one of the buttons of the menu, it would trigger a click.

This commit should now correctly trap and cancel events.
2023-06-08 14:38:08 +02:00
Joffrey JAFFEUX
65d61b87c1
FIX: prevents back history loop (#22001)
The following case would create the perception of a broken back button on desktop:

- open discourse on home page
- click chat button in header
- hit back button
- observes that we are still on the channel didn't navigate to homepage as we would have expected

The back button is actually working but it's in a loop. We were doing a `transitionTo` after finding the ideal channel to show, so the browser history would look something like this:

- home
- chat index
- channel page

When hitting back, we would go to chat index which would run the same logic and transition us to channel page.

This change will use `replaceWith` to replace the chat index step by the channel step, this way our history will now look like this:

- home
- channel page

Hitting back will now correctly bring us to home.
2023-06-08 14:35:29 +02:00
Joffrey JAFFEUX
6513ca69da
UX: improves chat message long press and touch (#21984)
This commit attempts to refactor our long press logic to make it more resilient and precise.

With this improvement two very UX/UI changes have been made:
- scale animation on long press
- prevents click on reaction to propagate to the message which would cause the active state of the message to trigger
2023-06-08 08:21:32 +02:00
Martin Brennan
482ef0782d
FIX: Do not allow blank chat messages (#21968)
This fixes an issue where a user could send an empty
string as a chat message .e.g '   ' and the message would
be posted. We don't want this, we need to strip the message
first before validating for length etc.
2023-06-08 16:06:09 +10:00
Martin Brennan
e48750281e
FIX: Pasting files into chat was not working (#21995)
Followup to e6c6c342d9,
we missed one part of this refactor which was to give
the correct composer element reference to ChatComposerUploads.
Without this the pasteEventListener for uploads was not
bound so uploading via paste did not work.

I tried to test this, and though I can write binary/text to
the clipboard and paste it into the composer, it does not
seem to be possible to end up with a paste event that
has clipboardData.files filled in, which is what is used
for the uploads. I think this is a restriction of JS
generally, and there doesn't seem to be a way to work around
it, so unfortunately we have to have no test for this still.
2023-06-08 13:03:55 +10:00
Joffrey JAFFEUX
699f3e7014
FIX: correctly set value on textarea interactor (#21990)
This would mostly work without it by mutation but could cause subtle bugs.
2023-06-08 01:21:30 +02:00
Bianca Nenciu
10ee92656c
FIX: Send TL2 promotion message to correct user (#21978)
Usually, when a user is promoted to TL2 two messages are sent. The
first one is a system message 'tl2_promotion_message' which triggers a
'system_message_sent' Discourse event.

When the event is fired and if Discourse Narrative Bot is enabled, then
a second message is sent to the recipient of the first message. The
recipients was determined by looking at the list of users that can
access that topic and pick the last one. This method does not work if
'site_contact_group_name' site setting is set because it adds the group
in the list of recipients.

A solution to this problem would have been to select the last user in
the list of 'topic_allowed_users', but an even better solution is to
pass the name of the recipients when the 'system_message_sent'
Discourse event is fired.
2023-06-07 22:51:24 +03:00
Joffrey JAFFEUX
e6c6c342d9
REFACTOR: composer/thread (#21910)
This commit contains multiple changes to improve the composer behavior especially in the context of a thread:

- Generally rename anything of the form `chatChannelThread...` to `chatThread...``
- Moves the textarea interactor instance inside the composer server
- Improves the focus state and closing of panel related to the use of the Escape shortcut
- Creates `Chat::ThreadList` as a component instead of having `Chat::Thread::ListItem` and others which could imply they were children of a the `Chat::Thread` component
2023-06-07 21:49:15 +02:00
Joffrey JAFFEUX
330137e7e4
FIX: Non-Interfering Backdrop Clicks (#21916)
Previously, there was an issue where closing the message actions menu on mobile would unintentionally trigger a click event on an element below it, such as a thread indicator or a reaction. With the recent fix, this problem has been resolved. Now, when you close the menu, it will no longer interfere with or activate any elements positioned underneath it.
2023-06-07 11:40:43 +02:00
chapoi
86facadec1
FIX: apply chat header icon indicator style to urgent only (#21967)
* FIX: apply chat header icon indicator style to urgent only

* UX: smaller padding
2023-06-07 06:42:51 +02:00
chapoi
9809103ed9
UX: fix number cutoff in header chat indicator (#21946)
In the chat header indicator, expand to a pill when the number reaches
N digits, and also display 99+ if the number is over 99.
2023-06-07 11:42:08 +10:00
Alan Guo Xiang Tan
41f8bff2c3
DEV: Remove superfluous js: true metadata (#21960)
Why this change?

It is very unlikely that we need to ever JS for system tests considering
that we rely on a JS framework on the frontend.
2023-06-07 09:26:58 +08:00
Martin Brennan
69eecf92d0
FIX: Use a default hashtag icon color for user with no permission (#21825)
One user can create a post or chat message with a hashtag they
have permission to use, but then when other users look at that
post they will see an empty space next to the hashtag because they
do not have the permission to load the colors in CSS classes for
the related category.

This fixes the issue by adding a default color with a special
CSS class if the user doesn't have permission to see the linked
channel/category on the hashtag.
2023-06-07 10:15:39 +10:00
Discourse Translator Bot
9661a8c214
Update translations (#21950) 2023-06-06 15:36:51 +02:00
Andrei Prigorshnev
b7a66bd6ad
DEV: Use await when sending chat messages (#21915)
This is a follow-up to d086888, I forgot to update these places in that commit.
2023-06-06 13:58:15 +04:00
chapoi
8c4cbd748d
UX: fix greyed out add button in chat composer when focussed (#21947) 2023-06-06 11:18:50 +02:00
Joffrey JAFFEUX
95a51b7d8a
FIX: correctly set last message bus ids on resync (#21911)
Replaces `channel.meta.message_bust_last_ids` on full resync instead of restarting the subscriptions, which was moreover not using a correct id.
2023-06-02 18:06:13 +02:00
chapoi
d40649c648
UX: chat channel header icons (#21887)
* UX: BEM fix for has-unreads

* UX: small refactor for chat channel header icons

* UX: refactor chat thread unread indicator

* UX: channel header thread icon hover styling

* DEV: Spec fixes

* UX: fix font + line-height

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
2023-06-02 10:34:19 +02:00
Alan Guo Xiang Tan
876734bcb6
DEV: Partially revert d1924c7328 (#21895)
Just remove the assertions for now as they are a constant source of
tests flakiness.
2023-06-02 06:35:42 +08:00
Joffrey JAFFEUX
676b558265
FIX: correctly resubscribe after restart (#21891)
Few weeks ago we implemented `onPresenceChangeCallback` to re-sync chat channels state when going back to a long time inactive tab. This codepath however contained a bug as we were reseting all subscriptions but only restarting global subscriptions and not per channel subscriptions.

This commit should correctly ensure we correctly do so. It's sadly very hard to test time related changes in system specs.

Co-authored-by: Martin Brennan <mjrbrennan@gmail.com>
2023-06-01 19:00:54 +02:00
Alan Guo Xiang Tan
d1924c7328
DEV: Update checks in chat channel and thread page objects (#21889)
What is the problem?

We were calling out to methods that calls `has_css?` or `has_selector?`
which returns a boolean. Since we are not using the return value, it
means the methods can be deemed unnecessary. However, we do want those
checks and this commit adds the necessarily assertions to make use of
the return values.
2023-06-01 22:31:01 +08:00
Andrei Prigorshnev
bb21476f68
FIX: Do not add mentioned groups as mentioned users (#21867)
When a user type a message with mentions, the autocomplete popup 
may suggest users or groups. We were adding all these object to 
the `currentMessage.mentionedUsers` collection, while we should 
have been adding only users. A group added to that collection led to 
the error later when trying to update user status on mentions.
2023-06-01 15:55:59 +04:00
Andrei Prigorshnev
d086888549
DEV: Make chatMessage.cook function async (#21829)
This will make it simpler to work with this code. This also can make this code more stable and increase stability of our test suite.

Cooked message now will be available immediately after cooking, it wasn't the case before:

    await message.cook();
    const cooked = message.cooked;


This also removes a call to `message.cook()` from message fabricator. Alternatively we may leave the call there and make the fabricator function async, but I fill it's better this way. If someone needs to test something related to cooked message, they can either pass cooked text to fabricator:

    message = fabricators.message({ cooked: "<p>cooked</p>" });

or call `message.cook()` after fabrication:

    message = fabricators.message({ message: "raw message" });
    await message.cook()
2023-06-01 13:39:32 +04:00
Alan Guo Xiang Tan
30e4ebd19b
Revert "DEV: Update checks in chat channel and thread page objects (#21875)" (#21883)
This reverts commit ddf4ecba04.

Causing a flaky test to appear:

```
main $ LOAD_PLUGINS=1 rspec plugins/chat/spec/system/chat/composer/shortcuts/channel_spec.rb

Randomized with seed 17765
.....F..

Failures:

  1) Chat | composer | shortcuts | channel when using ArrowUp when last message is staged does not edit a message
     Failure/Error: channel_page.send_message
       expected `#<PageObjects::Components::Chat::Messages:0x00007fe823ac1710 @context=".chat-channel">.has_message?({:persisted=>true, :text=>"2"})` to be truthy, got false

     [Screenshot Image]: /home/tgxworld/work/discourse/tmp/capybara/failures_r_spec_example_groups_chat_composer_shortcuts_channel_when_using_arrow_up_when_last_message_is_staged_does_not_edit_a_message_148.png
```
2023-06-01 16:59:03 +08:00
Andrei Prigorshnev
576d389ded
Add a test (#21866)
This adds a test for the fix made in 6c3a513.
2023-06-01 11:30:22 +04:00
Alan Guo Xiang Tan
ddf4ecba04
DEV: Update checks in chat channel and thread page objects (#21875)
What is the problem?

We were calling out to methods that calls `has_css?` or `has_selector?`
which returns a boolean. Since we are not using the return value, it
means the methods can be deemed unnecessary. However, we do want those
checks and this commit adds the necessarily assertions to make use of
the return values.
2023-06-01 15:25:11 +08:00
Joffrey JAFFEUX
9ba333808f
FIX: prevents admins to be silenced (#21854)
Currently in chat it was possible to have TL4 users to flag admins and silence them, this change should ensure it's never possible.
2023-06-01 08:36:11 +02:00
Alan Guo Xiang Tan
6fec9628a4
DEV: Use has_no_css? instead of !has_css? (#21874)
If we're asserting that something is missing, we want to use
`has_no_css?` instead of `!has_css?` since `has_css?` will wait the full
capybara default wait time before return if the selector is not present.
2023-06-01 10:41:43 +08:00
Sam
c2332d7505
FEATURE: reduce avatar sizes to 6 from 20 (#21319)
* FEATURE: reduce avatar sizes to 6 from 20

This PR introduces 3 changes:

1. SiteSetting.avatar_sizes, now does what is says on the tin.
previously it would introduce a large number of extra sizes, to allow for
various DPIs. Instead we now trust the admin with the size list.

2. When `avatar_sizes` changes, we ensure consistency and remove resized
avatars that are not longer allowed per site setting. This happens on the
12 hourly job and limited out of the box to 20k cleanups per cycle, given
this may reach out to AWS 20k times to remove things.

3.Our default avatar sizes are now "24|48|72|96|144|288" these sizes were
very specifically picked to limit amount of bluriness introduced by webkit.
Our avatars are already blurry due to 1px border, so this corrects old blur.

This change heavily reduces storage required by forums which simplifies
site moves and more.

Co-authored-by: David Taylor <david@taylorhq.com>
2023-06-01 10:00:01 +10:00
Joffrey JAFFEUX
7b7c4c383a
UX: followups to #1f37fe5 (#21859)
- ensures buttons are aligned to the bottom
- makes the emoji icon tertiary as initially intended
- correctly sets the icon scale of the sending button
2023-05-31 16:58:31 +02:00
chapoi
1f37fe5fa5
UX: chat composer buttons refactor + emoji (#21852)
- Made the emoji btn blue when composer is focused
- Moved everything chat-composer-button to its own file and BEM-ified it and making the choice to only work with our own is-disabled definition instead of with the attribute :disabled, for consistency
2023-05-31 15:12:35 +02:00
Joffrey JAFFEUX
f189c20578
DEV: ensures thread list has finished loading (#21855)
This should fix this failure:

```
Failures:

  1) Thread list in side panel | full page when there are no threads that the user is participating in shows a message
     Failure/Error: measurement = Benchmark.measure { example.run }
       expected to find text "You are not participating in any threads in this channel." in "Community\nEverything\nMy Posts\nMore\nMessages\nInbox\nChannels\nRandom 25\nPersonal chat\nRandom 25\nShowing all messages\nOngoing discussions"
```

The screenshot failure was clearly showing the spinner still being present.
2023-05-31 15:04:34 +02:00
Joffrey JAFFEUX
80c18b97b4
FIX: uses DiscourseURL.routeTo for drawer transitions (#21850)
Calling `transitionTo` directly was bypassing various custom codepaths of core.
2023-05-31 10:44:26 +02:00
Joffrey JAFFEUX
473992bd36
DEV: introduces Chat::Thread::ListItem in styleguide (#21851) 2023-05-31 10:29:38 +02:00
Discourse Translator Bot
4e99ef3952
Update translations (#21827) 2023-05-31 09:15:16 +02:00
Joffrey JAFFEUX
7c4d229f37
FIX: applies getURL on both app and chat URLs (#21847) 2023-05-31 01:30:54 +02:00
Joffrey JAFFEUX
852086e888
FIX: correctly uses getURL to open full page (#21843) 2023-05-31 00:52:27 +02:00
Joffrey JAFFEUX
6c3a51328c
FIX: removes destroyed mentioned used (#21841)
This would generate a 500 as we would call id on a nil object.
2023-05-31 00:21:09 +02:00
Joffrey JAFFEUX
906e053f32
FIX: recover by showing drawer index on 404 (#21839)
If the drawer receives an unexpected route, attempt to show the index. This is probably a more serious issue with subfolder but should limit the effects.
2023-05-30 23:51:55 +02:00
Jarek Radosz
3569a48b2d
DEV: Rescue the timeout error for a better spec cleanup (#21826)
Rescuing them still makes timing-out tests fail but doesn't break `after` spec cleanup (which could trigger more errors) Using custom error class to avoid any other possible timeout-catching code.

Also:
* remove an unnecessary `.select { |x| x.size > 0 }`
* fix a typo in a test title
2023-05-30 19:14:54 +02:00
Joffrey JAFFEUX
111ac4c7f2
FIX: call composer reset with correct params (#21777)
We were calling reset without the proper params which was causing errors in the console. This commit does the following changes:

- ensures `composer.cancel()` is the only way to cancel editing/reply
- adds a `draftSaved` property to chat message to allow for better tests
- writes a spec to ensure the flow is correct
- adds more page objects for better tests
- homogenize the default state of objects on chat message

Co-authored-by: Martin Brennan <martin@discourse.org>
2023-05-30 18:37:30 +02:00
Joffrey JAFFEUX
67102f7e4e
UX: deletes a message when editing to blank (#21785)
Editing a message to an empty string and sending it, will delete it.

This commit also refactors a lot of channel/thread composer shortcuts specs.

---

This commit also includes various spec fixes which have been flakey while finishing this pull request.
2023-05-30 18:15:34 +02:00
Andrei Prigorshnev
6491be9f2b
DEV: fix and enable flaky specs (#21753)
These specs were disabled in 786f7503. While investigating this, I found out that at some point `:user_membership` got deleted. It's hard to tell why exactly without investing more time, but it seems using `let!` instead of `fab!` solves the issue.

If in the future we decide to investigate why these tests were flaky with `fab!` to reproduce the failure run:

    LOAD_PLUGINS=1 rspec --seed 46586  plugins/chat/spec/mailers/user_notifications_spec.rb
2023-05-30 14:25:14 +04:00
Martin Brennan
6ec6cfccf8
FEATURE: Chat thread header indicator improvements (#21807)
This changes the thread header positioning of the
unread indicator to match the designs based on the route:

1. When the channel is open, show the indicator of # unread
   threads with the icon
2. When the threads list is open, show no indicator since
   you are on the list and can see which threads are unread
3. When a single thread is open, show the unread threads
   indicator along with a left < back button, with a label
   to show that this goes back to ongoing discussions

Drawer changes to come in another PR.
2023-05-30 10:10:07 +02:00
Alan Guo Xiang Tan
e7b55c11df
DEV: Speed chat channel system test (#21820)
Why is this change required?

In the `PageObjects::Components::Chat::Messages#has_no_message?` method,
it ended up calling `has_selector` when trying to assert that the
selector is not present. This is an anti-pattern which results in us
waiting the full Capybara default wait time
2023-05-30 12:44:47 +08:00
Alan Guo Xiang Tan
289fb8f29c
DEV: Remove unnecessary wait for chat transcript system test (#21819)
What is this change required?

In the `chat/spec/system/transcript_spec.rb` test, there is a helper
method that uses `page.has_css?` in a conditional but it do not
specify a wait time and hence the default Capybara default max wait
time is used. However, there is no need for us to be waiting here so
we specify the `wait: 0` option.
2023-05-30 12:44:19 +08:00
Joffrey JAFFEUX
5abe98afb5
DEV: faster browse page spec (#21814) 2023-05-29 23:21:10 +02:00
Martin Brennan
c57ae992b3
FIX: Page size edge case for null last_read_message_id (#21811)
Followup 55ef2d0698.

In the cases where the user has no last_read_message_id for
a channel, we want to make sure that a page_size is set for
the ChannelViewBuilder + MessagesQuery, otherwise we end up
loading way more messages than needed (the additional message
loading was fixed in the last commit).
2023-05-29 20:12:01 +02:00