Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Mark all chat channels read with a shortcut #20629

Merged
merged 19 commits into from
Mar 22, 2023

Conversation

martin-brennan
Copy link
Contributor

@martin-brennan martin-brennan commented Mar 10, 2023

This commit adds a keyboard shortcut (Shift+ESC) for chat which marks all
of the chat channels that the user is currently a following member of as read,
updating their last_read_message_id. This is done via a new service.

It also includes some refactors and controller changes:

  • The old mark message read route from ChatController is now supplanted
    by the Chat::Api::ReadsController#update route.
  • The new controller can handle either marking a single or all messages read,
    and uses the correct service based on the route and params.
  • The UpdateUserLastRead service is now used (it wasn't before), and has been slightly
    updated to just use the guardian user ID.

@github-actions github-actions bot added the chat PRs which include a change to Chat plugin label Mar 10, 2023
@martin-brennan martin-brennan force-pushed the feature/mark-all-channels-unread branch from fc3c98d to f11c8ae Compare March 10, 2023 04:17
@martin-brennan martin-brennan changed the title WIP: Mark all chat channels read FEATURE: Mark all chat channels read with a shortcut Mar 10, 2023
@martin-brennan martin-brennan marked this pull request as ready for review March 10, 2023 04:55
@jjaffeux jjaffeux force-pushed the feature/mark-all-channels-unread branch from 0554381 to 5417dc7 Compare March 18, 2023 18:03
@jjaffeux
Copy link
Contributor

I fixed the conflicts following the move to zeitwerk autoloading @martin-brennan, just in case I took a patch file before doing the force-push:

20629.patch.txt

@martin-brennan
Copy link
Contributor Author

@jjaffeux I think this is good for another look now, changed the routes 👍 Though I haven't made any changes for the timestamp thing, I think we can do that separately?

@@ -17,6 +17,8 @@
post "/channels/:channel_id/memberships/me" => "channels_current_user_membership#create"
put "/channels/:channel_id/notifications-settings/me" =>
"channels_current_user_notifications_settings#update"
put "/channels/read/" => "reads#update_all"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry Im nitpicking here, but the _all is not needed IMO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But they both go to the same controller, are you saying they should still both be in the same endpoint with the switching based on params like I had before?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking two controllers... but you are right that might be weird, ok 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet, will leave as-is

@martin-brennan
Copy link
Contributor Author

@jjaffeux fixed the suggestions but just have one more question if you could please take a look

@martin-brennan martin-brennan merged commit a038115 into main Mar 22, 2023
@martin-brennan martin-brennan deleted the feature/mark-all-channels-unread branch March 22, 2023 03:24
ChadBoschert pushed a commit to apt-crowd/discourse that referenced this pull request Apr 26, 2023
This commit adds a keyboard shortcut (Shift+ESC) for chat which marks all
of the chat channels that the user is currently a following member of as read,
updating their `last_read_message_id`. This is done via a new service.

It also includes some refactors and controller changes:

* The old mark message read route from `ChatController` is now supplanted
  by the `Chat::Api::ReadsController#update` route.
* The new controller can handle either marking a single or all messages read,
  and uses the correct service based on the route and params.
* The `UpdateUserLastRead` service is now used (it wasn't before), and has been slightly
  updated to just use the guardian user ID.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chat PRs which include a change to Chat plugin
Development

Successfully merging this pull request may close these issues.

3 participants