FIX: Your own likes were missing on posts
This commit is contained in:
parent
20f84a364b
commit
47995d2d89
|
@ -52,9 +52,36 @@ export function buildButton(name, widget) {
|
|||
}
|
||||
}
|
||||
|
||||
function likeCount(attrs) {
|
||||
const count = attrs.likeCount;
|
||||
|
||||
if (count > 0) {
|
||||
const title = attrs.liked
|
||||
? count === 1
|
||||
? "post.has_likes_title_only_you"
|
||||
: "post.has_likes_title_you"
|
||||
: "post.has_likes_title";
|
||||
const icon = attrs.yours ? "d-liked" : "";
|
||||
const additionalClass = attrs.yours ? "my-likes" : "regular-likes";
|
||||
|
||||
return {
|
||||
action: "toggleWhoLiked",
|
||||
title,
|
||||
className: `button-count like-count highlight-action ${additionalClass}`,
|
||||
contents: count,
|
||||
icon,
|
||||
iconRight: true,
|
||||
addContainer: attrs.yours,
|
||||
titleOptions: { count: attrs.liked ? count - 1 : count }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
registerButton("like-count", likeCount);
|
||||
|
||||
registerButton("like", attrs => {
|
||||
if (!attrs.showLike) {
|
||||
return;
|
||||
return likeCount(attrs);
|
||||
}
|
||||
|
||||
const className = attrs.liked
|
||||
|
@ -85,30 +112,6 @@ registerButton("like", attrs => {
|
|||
return button;
|
||||
});
|
||||
|
||||
registerButton("like-count", attrs => {
|
||||
const count = attrs.likeCount;
|
||||
|
||||
if (count > 0) {
|
||||
const title = attrs.liked
|
||||
? count === 1
|
||||
? "post.has_likes_title_only_you"
|
||||
: "post.has_likes_title_you"
|
||||
: "post.has_likes_title";
|
||||
const icon = attrs.yours ? "d-liked" : "";
|
||||
const additionalClass = attrs.yours ? "my-likes" : "regular-likes";
|
||||
|
||||
return {
|
||||
action: "toggleWhoLiked",
|
||||
title,
|
||||
className: `button-count like-count highlight-action ${additionalClass}`,
|
||||
contents: count,
|
||||
icon,
|
||||
iconRight: true,
|
||||
titleOptions: { count: attrs.liked ? count - 1 : count }
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
registerButton("flag-count", attrs => {
|
||||
let className = "button-count";
|
||||
if (attrs.reviewableScorePendingCount > 0) {
|
||||
|
@ -344,7 +347,10 @@ export default createWidget("post-menu", {
|
|||
if (buttonAtts.before) {
|
||||
let before = this.attachButton(buttonAtts.before);
|
||||
return h("div.double-button", [before, button]);
|
||||
} else if (buttonAtts.addContainer) {
|
||||
return h("div.double-button", [button]);
|
||||
}
|
||||
|
||||
return button;
|
||||
}
|
||||
},
|
||||
|
|
|
@ -144,7 +144,7 @@ widgetTest("like count button", {
|
|||
actions_summary: [{ id: 2, count: 1, hidden: false, can_act: true }]
|
||||
});
|
||||
this.set("post", post);
|
||||
this.set("args", { likeCount: 1, showLike: true });
|
||||
this.set("args", { likeCount: 1 });
|
||||
},
|
||||
async test(assert) {
|
||||
assert.ok(find("button.like-count").length === 1);
|
||||
|
|
Loading…
Reference in New Issue