File tree Expand file tree Collapse file tree 4 files changed +23
-9
lines changed Expand file tree Collapse file tree 4 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ function Chat(props: any) {
20
20
let messageHistory = [ ]
21
21
22
22
for ( const message of channel . MessageHistory ) {
23
- messageHistory . push ( < Message Message = { message } /> )
23
+ messageHistory . push ( < Message Message = { message } key = { message . Id } /> )
24
24
}
25
25
26
26
return (
@@ -29,7 +29,7 @@ function Chat(props: any) {
29
29
< defs >
30
30
< filter id = "colorFilter" >
31
31
< feColorMatrix
32
- color-interpolation-filters = "sRGB"
32
+ colorInterpolationFilters = "sRGB"
33
33
type = "matrix"
34
34
values = "0.12 0 0 0 0
35
35
0 0.10 0 0 0
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ import React, { useState } from "react";
2
2
3
3
import "./ChatInput.scss" ;
4
4
import OutsideClickHandler from "react-outside-click-handler" ;
5
- import { Picker , Emoji } from "emoji-mart" ;
5
+ import { Picker , Emoji , EmojiData } from "emoji-mart" ;
6
6
import { SiteStateStore } from "../../../../../Shared/Globals" ;
7
7
import { SendMessage } from "../../../../../Shared/Actions/ServerActions" ;
8
8
@@ -19,12 +19,26 @@ function OnSubmitChatMessage(e: React.FormEvent<HTMLFormElement>) {
19
19
textInput . value = "" ;
20
20
}
21
21
22
+ function EmojiSelected ( setState : any , emoji : EmojiData )
23
+ {
24
+ const textInput = document . getElementsByClassName ( "chatInput" ) [ 0 ] . children [ 0 ] as HTMLInputElement ;
25
+
26
+ setState ( {
27
+ IsPicking : false
28
+ } ) ;
29
+
30
+ textInput . value = textInput . value . trimEnd ( ) ;
31
+ textInput . value += " " + emoji . colons + " " ;
32
+
33
+ textInput . focus ( ) ;
34
+ }
35
+
22
36
function ChatInput ( ) {
23
37
const [ state , setState ] = useState ( {
24
38
IsPicking : false
25
39
} ) ;
26
40
27
- const picker = < Picker autoFocus = { true } set = "twitter" title = "Select an Emoji..." />
41
+ const picker = < Picker autoFocus = { true } set = "twitter" title = "Select an Emoji..." onSelect = { e => EmojiSelected ( setState , e ) } />
28
42
29
43
return (
30
44
< div id = "ChatInput" >
Original file line number Diff line number Diff line change 62
62
position : relative ;
63
63
64
64
top : 27.5px ;
65
-
65
+
66
66
font-size : .9em ;
67
67
color : rgb (173 , 173 , 173 );
68
68
}
Original file line number Diff line number Diff line change @@ -18,15 +18,14 @@ function Message(props: MessageProps) {
18
18
19
19
let lastOffset = 0 ;
20
20
let match = regex . exec ( props . Message . Message ) ;
21
-
22
21
while ( match ) {
23
22
const previousText = props . Message . Message . substring (
24
23
lastOffset ,
25
24
match . index
26
25
) ;
27
26
28
27
if ( previousText . length )
29
- msg . push ( < span className = "msgPart" > { previousText } </ span > ) ;
28
+ msg . push ( < span className = "msgPart" key = { match . index + previousText } > { previousText } </ span > ) ;
30
29
31
30
lastOffset = match . index + match [ 0 ] . length ;
32
31
@@ -38,13 +37,14 @@ function Message(props: MessageProps) {
38
37
return emoji ? `:${ emoji . short_names [ 0 ] } :` : props . emoji
39
38
} ) as any }
40
39
size = { 22 }
40
+ key = { match . index + lastOffset }
41
41
/>
42
42
) ;
43
43
44
44
if ( emoji ) {
45
45
msg . push ( emoji ) ;
46
46
} else {
47
- msg . push ( < span className = "msgPart" > { match [ 0 ] } </ span > ) ;
47
+ msg . push ( < span key = { match . index + match [ 0 ] } className = "msgPart" > { match [ 0 ] } </ span > ) ;
48
48
}
49
49
50
50
match = regex . exec ( props . Message . Message ) ;
@@ -53,7 +53,7 @@ function Message(props: MessageProps) {
53
53
}
54
54
55
55
if ( lastOffset === 0 )
56
- msg . push ( < span className = "msgPart" > { props . Message . Message } </ span > ) ;
56
+ msg . push ( < span className = "msgPart" key = { props . Message . Message } > { props . Message . Message } </ span > ) ;
57
57
58
58
return (
59
59
< div id = "Message" >
You can’t perform that action at this time.
0 commit comments