11import * as Constants from '../../../constants/chat2'
2+ import * as Chat2Gen from '../../../actions/chat2-gen'
3+ import * as RouteTreeGen from '../../../actions/route-tree-gen'
24import * as WaitingConstants from '../../../constants/waiting'
35import * as Container from '../../../util/container'
46import * as Kb from '../../../common-adapters/mobile.native'
57import * as React from 'react'
68import * as Styles from '../../../styles'
9+ import DropView , { type DropItems } from '../../../common-adapters/drop-view.native'
710import Banner from '../bottom-banner/container'
811import InputArea from '../input-area/container'
912import InvitationToBlock from '../../blocking/invitation-to-block'
@@ -34,6 +37,7 @@ const LoadingLine = (p: {conversationIDKey: Types.ConversationIDKey}) => {
3437}
3538
3639const Conversation = React . memo ( function Conversation ( props : Props ) {
40+ const { conversationIDKey} = props
3741 const [ maxInputArea , setMaxInputArea ] = React . useState < number | undefined > ( undefined )
3842 const onLayout = React . useCallback ( ( e : LayoutEvent ) => {
3943 setMaxInputArea ( e . nativeEvent . layout . height )
@@ -42,44 +46,86 @@ const Conversation = React.memo(function Conversation(props: Props) {
4246 const innerComponent = (
4347 < Kb . BoxGrow onLayout = { onLayout } >
4448 < Kb . Box2 direction = "vertical" fullWidth = { true } style = { styles . innerContainer } >
45- < ThreadLoadStatus conversationIDKey = { props . conversationIDKey } />
46- < PinnedMessage conversationIDKey = { props . conversationIDKey } />
49+ < ThreadLoadStatus conversationIDKey = { conversationIDKey } />
50+ < PinnedMessage conversationIDKey = { conversationIDKey } />
4751 < ListArea
4852 requestScrollToBottomRef = { props . requestScrollToBottomRef }
4953 requestScrollDownRef = { props . requestScrollDownRef }
5054 requestScrollUpRef = { props . requestScrollUpRef }
5155 onFocusInput = { props . onFocusInput }
52- conversationIDKey = { props . conversationIDKey }
56+ conversationIDKey = { conversationIDKey }
5357 />
54- < LoadingLine conversationIDKey = { props . conversationIDKey } />
58+ < LoadingLine conversationIDKey = { conversationIDKey } />
5559 </ Kb . Box2 >
56- < InvitationToBlock conversationID = { props . conversationIDKey } />
57- < Banner conversationIDKey = { props . conversationIDKey } />
60+ < InvitationToBlock conversationID = { conversationIDKey } />
61+ < Banner conversationIDKey = { conversationIDKey } />
5862 < InputArea
5963 focusInputCounter = { props . focusInputCounter }
6064 jumpToRecent = { props . jumpToRecent }
6165 onRequestScrollDown = { props . onRequestScrollDown }
6266 onRequestScrollToBottom = { props . onRequestScrollToBottom }
6367 onRequestScrollUp = { props . onRequestScrollUp }
64- conversationIDKey = { props . conversationIDKey }
68+ conversationIDKey = { conversationIDKey }
6569 maxInputArea = { maxInputArea }
6670 />
6771 </ Kb . BoxGrow >
6872 )
73+
74+ const dispatch = Container . useDispatch ( )
75+ const onDropped = React . useCallback (
76+ ( items : DropItems ) => {
77+ const { attach, texts} = items . reduce (
78+ ( obj , i ) => {
79+ const { texts, attach} = obj
80+ if ( i . content ) {
81+ texts . push ( i . content )
82+ } else if ( i . originalPath ) {
83+ attach . push ( { outboxID : null , path : i . originalPath } )
84+ }
85+ return obj
86+ } ,
87+ { attach : new Array < { outboxID : null ; path : string } > ( ) , texts : new Array < string > ( ) }
88+ )
89+
90+ if ( texts . length ) {
91+ dispatch (
92+ Chat2Gen . createSetUnsentText ( {
93+ conversationIDKey,
94+ text : new Container . HiddenString ( texts . join ( '\r' ) ) ,
95+ } )
96+ )
97+ }
98+
99+ if ( attach . length ) {
100+ dispatch (
101+ RouteTreeGen . createNavigateAppend ( {
102+ path : [
103+ { props : { conversationIDKey, pathAndOutboxIDs : attach } , selected : 'chatAttachmentGetTitles' } ,
104+ ] ,
105+ } )
106+ )
107+ }
108+ } ,
109+ [ dispatch , conversationIDKey ]
110+ )
111+
69112 return (
70113 < Kb . Box style = { styles . innerContainer } >
71- < Kb . Box2 direction = "vertical" fullWidth = { true } fullHeight = { true } >
72- { props . threadLoadedOffline && < Offline /> }
73- { innerComponent }
74- </ Kb . Box2 >
75- < PortalHost name = "convOverlay" />
114+ < DropView style = { styles . dropView } onDropped = { onDropped } >
115+ < Kb . Box2 direction = "vertical" fullWidth = { true } fullHeight = { true } >
116+ { props . threadLoadedOffline && < Offline /> }
117+ { innerComponent }
118+ </ Kb . Box2 >
119+ < PortalHost name = "convOverlay" />
120+ </ DropView >
76121 </ Kb . Box >
77122 )
78123} )
79124
80125const styles = Styles . styleSheetCreate (
81126 ( ) =>
82127 ( {
128+ dropView : { flexGrow : 1 } ,
83129 innerContainer : {
84130 flex : 1 ,
85131 position : 'relative' ,
0 commit comments