@@ -32,6 +32,7 @@ import SettingsStore from "../settings/SettingsStore";
3232import { EMOJI , IEmoji , getEmojiFromUnicode } from '../emoji' ;
3333import { TimelineRenderingType } from '../contexts/RoomContext' ;
3434import * as recent from '../emojipicker/recent' ;
35+ import { mediaFromMxc } from "../customisations/Media" ;
3536
3637const LIMIT = 20 ;
3738
@@ -75,9 +76,15 @@ export default class EmojiProvider extends AutocompleteProvider {
7576 matcher : QueryMatcher < ISortedEmoji > ;
7677 nameMatcher : QueryMatcher < ISortedEmoji > ;
7778 private readonly recentlyUsed : IEmoji [ ] ;
78-
79+ emotes : Dictionary < string > ;
7980 constructor ( room : Room , renderingType ?: TimelineRenderingType ) {
8081 super ( { commandRegex : EMOJI_REGEX , renderingType } ) ;
82+ let emotesEvent = room ?. currentState . getStateEvents ( "m.room.emotes" , "" ) ;
83+ let rawEmotes = emotesEvent ? ( emotesEvent . getContent ( ) || { } ) : { } ;
84+ this . emotes = { } ;
85+ for ( let key in rawEmotes ) {
86+ this . emotes [ key ] = "<img class='mx_Emote' title=':" + key + ":'src=" + mediaFromMxc ( rawEmotes [ key ] ) . srcHttp + "/>" ;
87+ }
8188 this . matcher = new QueryMatcher < ISortedEmoji > ( SORTED_EMOJI , {
8289 keys : [ ] ,
8390 funcs : [ o => o . emoji . shortcodes . map ( s => `:${ s } :` ) ] ,
@@ -102,7 +109,20 @@ export default class EmojiProvider extends AutocompleteProvider {
102109 if ( ! SettingsStore . getValue ( "MessageComposerInput.suggestEmoji" ) ) {
103110 return [ ] ; // don't give any suggestions if the user doesn't want them
104111 }
105-
112+ let emojisAndEmotes = [ ...SORTED_EMOJI ] ;
113+ for ( let key in this . emotes ) {
114+ emojisAndEmotes . push ( {
115+ emoji :{ label :key ,
116+ shortcodes :[ this . emotes [ key ] ] ,
117+ hexcode :"" ,
118+ unicode :":" + key + ":" ,
119+
120+ } ,
121+ _orderBy :0
122+ } )
123+ }
124+ this . matcher . setObjects ( emojisAndEmotes ) ;
125+ this . nameMatcher . setObjects ( emojisAndEmotes ) ;
106126 let completions = [ ] ;
107127 const { command, range } = this . getCurrentCommand ( query , selection ) ;
108128
@@ -146,8 +166,8 @@ export default class EmojiProvider extends AutocompleteProvider {
146166 completions = completions . map ( c => ( {
147167 completion : c . emoji . unicode ,
148168 component : (
149- < PillCompletion title = { `: ${ c . emoji . shortcodes [ 0 ] } :` } aria-label = { c . emoji . unicode } >
150- < span > { c . emoji . unicode } </ span >
169+ < PillCompletion title = { c . emoji . shortcodes [ 0 ] } aria-label = { c . emoji . unicode } >
170+ < span > { this . emotes [ c . emoji . shortcodes [ 0 ] ] ? this . emotes [ c . emoji . shortcodes [ 0 ] ] : c . emoji . unicode } </ span >
151171 </ PillCompletion >
152172 ) ,
153173 range,
0 commit comments