Skip to content

Commit

Permalink
Fix showing if user has voted for reaction on post
Browse files Browse the repository at this point in the history
  • Loading branch information
dsevillamartin committed Jan 13, 2024
1 parent ae3c82c commit c1714d6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion js/src/@types/shims.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Reaction from '../common/models/Reaction';
declare module 'flarum/common/models/Post' {
export default interface Post {
reactionCounts(): Record<string, number>;
userReaction(): PostReaction | null;
userReaction(): number | undefined;

canReact(): boolean;
canDeletePostReactions(): boolean;
Expand Down
4 changes: 1 addition & 3 deletions js/src/forum/components/PostReactAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ export default class PostReactAction extends Component {

return Button.component(
{
className: `Button Button--flat Button-emoji-parent ${
this.post.userReaction() && this.post.userReaction() == reaction.id() && 'active'
}`,
className: `Button Button--flat Button-emoji-parent ${this.post.userReaction() == reaction.id() && 'active'}`,
onclick: canReact ? this.react.bind(this, reaction) : '',
'data-reaction': reaction.identifier(),
disabled: !canReact,
Expand Down
2 changes: 1 addition & 1 deletion js/src/forum/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ app.initializers.add('fof/reactions', () => {
Post.prototype.canReact = Model.attribute('canReact');
Post.prototype.canDeletePostReactions = Model.attribute('canDeletePostReactions');
Post.prototype.reactionCounts = Model.attribute('reactionCounts');
Post.prototype.userReaction = Model.attribute('userReaction');
Post.prototype.userReaction = Model.attribute('userReactionIdentifier');

Forum.prototype.reactions = Model.hasMany('reactions');

Expand Down

0 comments on commit c1714d6

Please sign in to comment.