-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat(snippets): reactions #377
Conversation
AH |
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.
(Partie 1/2)
Ça fait plaisir de voir un bon vieux CRUD. Mes commentaires c'est que du nommage à ce stade.
J'ai pas encore review le front, je fais ça tout de suite
}.freeze | ||
|
||
def initialize(snippet:, reaction_type:, user:) | ||
@user = 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.
Ça serait un bon cas d'utilisation pour Current.user
afin de skipper le passage de @user
à travers plusieurs couches nestées (View -> Component -> View -> ici) juste pour arriver ici.
(Pas bloquant, je dis juste pour garder en tête des refactos possibles)
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.
👏
Ready to merge quand tu te le sens, @pil0u. |
<% if @reactions.pluck(:user_id).include?(@user.id) %> | ||
<%= button_to "#{EMOTES[@reaction_type][:emote]} #{@reactions.count}", | ||
delete_reaction_path(id: @reactions.find_by(user: @user).id), | ||
method: :delete, | ||
class: "border border-aoc-green cursor-pointer duration-300 px-1.5 rounded-full transition-colors hover:bg-aoc-gray-darker" %> | ||
<% elsif @snippet.reactions.pluck(:user_id).include?(@user.id) %> | ||
<%= button_to "#{EMOTES[@reaction_type][:emote]} #{@reactions.count}", | ||
update_reaction_path(id: @snippet.reactions.find_by(user: @user).id), | ||
params: { reaction: { reaction_type: @reaction_type } }, | ||
method: :patch, | ||
class: "border border-aoc-gray-dark cursor-pointer duration-300 px-1.5 rounded-full transition-colors hover:bg-aoc-gray-darker" %> | ||
<% else %> | ||
<%= button_to "#{EMOTES[@reaction_type][:emote]} #{@reactions.count}", | ||
reactions_path(@snippet.id), | ||
params: { reaction: { reaction_type: @reaction_type } }, | ||
class: "border border-aoc-gray-dark px-1.5 duration-300 rounded-full transition-colors #{'cursor-pointer hover:bg-aoc-gray-darker' unless @snippet.reactions.pluck(:user_id).include?(@user.id)}" %> | ||
<% end %> |
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.
Simplifiable avec un chouïa de dynamisme et en passant par 1 seule action de controller au lieu de trois (que ça soit le back qui gère cette logique).
Mais pas bloquant, on pourra refaire plus tard.
Summary of changes and context
closes #269
This is a MVP for the snipppets' reaction system.
Eventually I'd like to add a transition to the tooltip so that it fades in from the bottom but it's gonna need JavaScript.
I also want to be able to update reactions without reloading the page, or at least without scrolling back at the top.
It was might doable with Turbo ? I haven't really used it yet, otherwise it should easily be doable with JavaScript too.
Le.Wagon.x.Advent.of.Code.-.Brave.2023-11-30.20-04-11.mp4
I don't like the fact that one of the
Snippets::ReactionComponent::initialize
attributes is calledemote
instead ofcontent
but apparently the latter is a reserved keyword so I had to change it.The reason I went with
content
is because that's what Github does with their API.Sanity checks