mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Clean up chat-message-reaction (#27465)
* remove an unused service injection (and sort the rest) * remove unused prop * inline an arg check * remove an unnecessary `?.` operator * sort element attributes
This commit is contained in:
parent
5361c3704d
commit
a8567d409d
@ -1,5 +1,5 @@
|
|||||||
import Component from "@glimmer/component";
|
import Component from "@glimmer/component";
|
||||||
import { cached, tracked } from "@glimmer/tracking";
|
import { cached } from "@glimmer/tracking";
|
||||||
import { on } from "@ember/modifier";
|
import { on } from "@ember/modifier";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import { service } from "@ember/service";
|
import { service } from "@ember/service";
|
||||||
@ -11,15 +11,12 @@ import { emojiUnescape, emojiUrlFor } from "discourse/lib/text";
|
|||||||
import { getReactionText } from "discourse/plugins/chat/discourse/lib/get-reaction-text";
|
import { getReactionText } from "discourse/plugins/chat/discourse/lib/get-reaction-text";
|
||||||
|
|
||||||
export default class ChatMessageReaction extends Component {
|
export default class ChatMessageReaction extends Component {
|
||||||
@service capabilities;
|
|
||||||
@service currentUser;
|
@service currentUser;
|
||||||
@service tooltip;
|
|
||||||
@service site;
|
@service site;
|
||||||
|
@service tooltip;
|
||||||
@tracked isActive = false;
|
|
||||||
|
|
||||||
registerTooltip = modifier((element) => {
|
registerTooltip = modifier((element) => {
|
||||||
if (this.disableTooltip || !this.popoverContent?.length) {
|
if (this.args.disableTooltip || !this.popoverContent?.length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,14 +30,10 @@ export default class ChatMessageReaction extends Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
instance?.destroy();
|
instance.destroy();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
get disableTooltip() {
|
|
||||||
return this.args.disableTooltip ?? false;
|
|
||||||
}
|
|
||||||
|
|
||||||
get showCount() {
|
get showCount() {
|
||||||
return this.args.showCount ?? true;
|
return this.args.showCount ?? true;
|
||||||
}
|
}
|
||||||
@ -75,17 +68,16 @@ export default class ChatMessageReaction extends Component {
|
|||||||
<template>
|
<template>
|
||||||
{{#if (and @reaction this.emojiUrl)}}
|
{{#if (and @reaction this.emojiUrl)}}
|
||||||
<button
|
<button
|
||||||
|
{{on "click" this.handleClick passive=true}}
|
||||||
|
{{this.registerTooltip}}
|
||||||
type="button"
|
type="button"
|
||||||
|
title={{this.emojiString}}
|
||||||
|
data-emoji-name={{@reaction.emoji}}
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
class={{concatClass
|
class={{concatClass
|
||||||
"chat-message-reaction"
|
"chat-message-reaction"
|
||||||
(if @reaction.reacted "reacted")
|
(if @reaction.reacted "reacted")
|
||||||
(if this.isActive "-active")
|
|
||||||
}}
|
}}
|
||||||
data-emoji-name={{@reaction.emoji}}
|
|
||||||
title={{this.emojiString}}
|
|
||||||
{{on "click" this.handleClick passive=true}}
|
|
||||||
{{this.registerTooltip}}
|
|
||||||
>
|
>
|
||||||
<img
|
<img
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
Loading…
Reference in New Issue
Block a user