[go: up one dir, main page]

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

DEV: add outlet wrapper for small user list #29763

Merged
merged 4 commits into from
Nov 20, 2024

Conversation

branquinhoaa
Copy link
Contributor
  • This PR adds one extra argument to an existing outlet
  • Adds another outlet for users like list small-user-list-internal
  • Move the function smallUserAtts to a service so it can be extensible and avoids code duplication

@branquinhoaa branquinhoaa marked this pull request as ready for review November 14, 2024 20:59
import { userPath } from "discourse/lib/url";

export default class UserListAtts extends Service {
smallUserAtts(user) {
Copy link
Contributor

Choose a reason for hiding this comment

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

would it be possible to move this to a User model method instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hey @CvX I took a look at this and tried to refactor as you asked.

This function is generic and works for multiple types of user models (user, post action user, post reader) so I would need to duplicate the logic. Apart from that, some of these models are not explicit defined (ie:post action user).

Let me know if you still think it is better to move or if you have any other idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, so let's move it to lib directory. Services are a better fit for stuff with state and/or multiple related methods (used by various components, etc) but here we have just a single-input utility function.

also, can you rename atts to attrs? 😅 that contraction is way more common in core

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@CvX as we discussed in chat, I replaced the implementation to use Value Transformers and it works like a charm! thank you for the tip 👯

…t.gjs

Co-authored-by: Jarek Radosz <jradosz@gmail.com>
@branquinhoaa branquinhoaa merged commit 71a8d48 into main Nov 20, 2024
17 checks passed
@branquinhoaa branquinhoaa deleted the dev/add-user-list-for-likes branch November 20, 2024 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants