-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Conversation
a73fb69
to
11be2aa
Compare
import { userPath } from "discourse/lib/url"; | ||
|
||
export default class UserListAtts extends Service { | ||
smallUserAtts(user) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 👯
app/assets/javascripts/discourse/app/components/small-user-list.gjs
Outdated
Show resolved
Hide resolved
…t.gjs Co-authored-by: Jarek Radosz <jradosz@gmail.com>
small-user-list-internal
smallUserAtts
to a service so it can be extensible and avoids code duplication