mirror of
https://github.com/tulir/gomuks.git
synced 2025-04-20 10:33:41 -05:00
web/timeline: add support for rendering custom emoji reactions
This commit is contained in:
parent
27f1d0f3e4
commit
65b221d38e
2 changed files with 17 additions and 5 deletions
|
@ -141,7 +141,11 @@ div.event-content > div.event-reactions {
|
|||
gap: .25rem;
|
||||
margin: .25rem 0;
|
||||
|
||||
> span.reaction {
|
||||
> div.reaction {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: .25rem;
|
||||
|
||||
background-color: #efe;
|
||||
border: 1px solid #ada;
|
||||
border-radius: 2rem;
|
||||
|
@ -151,6 +155,10 @@ div.event-content > div.event-reactions {
|
|||
text-overflow: ellipsis;
|
||||
overflow: hidden;
|
||||
max-width: 20rem;
|
||||
|
||||
> img.reaction-emoji {
|
||||
height: 1.5rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
// You should have received a copy of the GNU Affero General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
import React, { use, useCallback } from "react"
|
||||
import { getAvatarURL } from "@/api/media.ts"
|
||||
import { getAvatarURL, getMediaURL } from "@/api/media.ts"
|
||||
import { RoomStateStore, useRoomState } from "@/api/statestore"
|
||||
import { EventID, MemDBEvent, MemberEventContent, UnreadType } from "@/api/types"
|
||||
import { isEventID } from "@/util/validation.ts"
|
||||
|
@ -41,9 +41,13 @@ const formatShortTime = (time: Date) =>
|
|||
|
||||
const EventReactions = ({ reactions }: { reactions: Record<string, number> }) => {
|
||||
return <div className="event-reactions">
|
||||
{Object.entries(reactions).map(([reaction, count]) => count > 0 ? <span key={reaction} className="reaction" title={reaction}>
|
||||
<span className="reaction">{reaction}</span> <span className="reaction-count">{count}</span>
|
||||
</span> : null)}
|
||||
{Object.entries(reactions).map(([reaction, count]) => count > 0 ?
|
||||
<div key={reaction} className="reaction" title={reaction}>
|
||||
{reaction.startsWith("mxc://")
|
||||
? <img className="reaction-emoji" src={getMediaURL(reaction)} alt=""/>
|
||||
: <span className="reaction-emoji">{reaction}</span>}
|
||||
<span className="reaction-count">{count}</span>
|
||||
</div> : null)}
|
||||
</div>
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue