@@ -4,7 +4,7 @@ import * as Container from '../../../../util/container'
44import * as Styles from '../../../../styles'
55import * as RPCChatTypes from '../../../../constants/types/rpc-chat-gen'
66import shallowEqual from 'shallowequal'
7- import { ConversationIDKeyContext , SnippetContext } from './contexts'
7+ import { ConversationIDKeyContext , SnippetContext , SnippetDecorationContext } from './contexts'
88
99type Props = {
1010 isDecryptingSnippet : boolean
@@ -13,7 +13,8 @@ type Props = {
1313 isInWidget ?: boolean
1414}
1515
16- const SnippetDecoration = ( type : Kb . IconType , color : string , tooltip ?: string ) => {
16+ const SnippetDecoration = ( p : { type : Kb . IconType ; color : string ; tooltip ?: string } ) => {
17+ const { type, color, tooltip} = p
1718 const icon = (
1819 < Kb . Icon
1920 color = { color }
@@ -28,23 +29,29 @@ const SnippetDecoration = (type: Kb.IconType, color: string, tooltip?: string) =
2829const Snippet = React . memo ( function Snippet ( p : { isSelected ?: Boolean ; style : Styles . StylesCrossPlatform } ) {
2930 const snippet = React . useContext ( SnippetContext )
3031 const { isSelected, style} = p
32+
33+ const decoration = React . useContext ( SnippetDecorationContext )
3134 let snippetDecoration : React . ReactNode
3235 let exploded = false
3336 const defaultIconColor = isSelected ? Styles . globalColors . white : Styles . globalColors . black_20
3437
35- switch ( snippetDecoration ) {
38+ switch ( decoration ) {
3639 case RPCChatTypes . SnippetDecoration . pendingMessage :
37- snippetDecoration = SnippetDecoration ( 'iconfont-hourglass' , defaultIconColor , 'Sending…' )
40+ snippetDecoration = (
41+ < SnippetDecoration type = "iconfont-hourglass" color = { defaultIconColor } tooltip = "Sending…" />
42+ )
3843 break
3944 case RPCChatTypes . SnippetDecoration . failedPendingMessage :
40- snippetDecoration = SnippetDecoration (
41- 'iconfont-exclamation' ,
42- isSelected ? Styles . globalColors . white : Styles . globalColors . red ,
43- 'Failed to send'
45+ snippetDecoration = (
46+ < SnippetDecoration
47+ type = "iconfont-exclamation"
48+ color = { isSelected ? Styles . globalColors . white : Styles . globalColors . red }
49+ tooltip = "Failed to send"
50+ />
4451 )
4552 break
4653 case RPCChatTypes . SnippetDecoration . explodingMessage :
47- snippetDecoration = SnippetDecoration ( ' iconfont-timer-solid' , defaultIconColor )
54+ snippetDecoration = < SnippetDecoration type = " iconfont-timer-solid" color = { defaultIconColor } />
4855 break
4956 case RPCChatTypes . SnippetDecoration . explodedMessage :
5057 snippetDecoration = (
@@ -60,25 +67,25 @@ const Snippet = React.memo(function Snippet(p: {isSelected?: Boolean; style: Sty
6067 exploded = true
6168 break
6269 case RPCChatTypes . SnippetDecoration . audioAttachment :
63- snippetDecoration = SnippetDecoration ( ' iconfont-mic-solid' , defaultIconColor )
70+ snippetDecoration = < SnippetDecoration type = " iconfont-mic-solid" color = { defaultIconColor } />
6471 break
6572 case RPCChatTypes . SnippetDecoration . videoAttachment :
66- snippetDecoration = SnippetDecoration ( ' iconfont-film-solid' , defaultIconColor )
73+ snippetDecoration = < SnippetDecoration type = " iconfont-film-solid" color = { defaultIconColor } />
6774 break
6875 case RPCChatTypes . SnippetDecoration . photoAttachment :
69- snippetDecoration = SnippetDecoration ( ' iconfont-camera-solid' , defaultIconColor )
76+ snippetDecoration = < SnippetDecoration type = " iconfont-camera-solid" color = { defaultIconColor } />
7077 break
7178 case RPCChatTypes . SnippetDecoration . fileAttachment :
72- snippetDecoration = SnippetDecoration ( ' iconfont-file-solid' , defaultIconColor )
79+ snippetDecoration = < SnippetDecoration type = " iconfont-file-solid" color = { defaultIconColor } />
7380 break
7481 case RPCChatTypes . SnippetDecoration . stellarReceived :
75- snippetDecoration = SnippetDecoration ( ' iconfont-stellar-request' , defaultIconColor )
82+ snippetDecoration = < SnippetDecoration type = " iconfont-stellar-request" color = { defaultIconColor } />
7683 break
7784 case RPCChatTypes . SnippetDecoration . stellarSent :
78- snippetDecoration = SnippetDecoration ( ' iconfont-stellar-send' , defaultIconColor )
85+ snippetDecoration = < SnippetDecoration type = " iconfont-stellar-send" color = { defaultIconColor } />
7986 break
8087 case RPCChatTypes . SnippetDecoration . pinnedMessage :
81- snippetDecoration = SnippetDecoration ( ' iconfont-pin-solid' , defaultIconColor )
88+ snippetDecoration = < SnippetDecoration type = " iconfont-pin-solid" color = { defaultIconColor } />
8289 break
8390 default :
8491 snippetDecoration = null
@@ -296,7 +303,10 @@ const styles = Styles.styleSheetCreate(
296303 outerBox : {
297304 ...Styles . globalStyles . flexBoxRow ,
298305 } ,
299- snippetDecoration : { alignSelf : 'flex-start' } ,
306+ snippetDecoration : Styles . platformStyles ( {
307+ common : { alignSelf : 'flex-start' } ,
308+ isMobile : { marginRight : 4 } ,
309+ } ) ,
300310 typingSnippet : { } ,
301311 youAreResetText : Styles . platformStyles ( {
302312 isElectron : {
0 commit comments