Changeset View
Changeset View
Standalone View
Standalone View
native/chat/chat-input-bar.react.js
Show All 22 Lines | import { | ||||
updateDraftActionType, | updateDraftActionType, | ||||
} from 'lib/actions/draft-actions'; | } from 'lib/actions/draft-actions'; | ||||
import { | import { | ||||
joinThreadActionTypes, | joinThreadActionTypes, | ||||
joinThread, | joinThread, | ||||
newThreadActionTypes, | newThreadActionTypes, | ||||
} from 'lib/actions/thread-actions'; | } from 'lib/actions/thread-actions'; | ||||
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors'; | import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors'; | ||||
import { | |||||
relativeMemberInfoSelectorForMembersOfThread, | |||||
userStoreSearchIndex, | |||||
} from 'lib/selectors/user-selectors'; | |||||
import { localIDPrefix, trimMessage } from 'lib/shared/message-utils'; | import { localIDPrefix, trimMessage } from 'lib/shared/message-utils'; | ||||
import SearchIndex from 'lib/shared/search-index'; | |||||
import { | import { | ||||
threadHasPermission, | threadHasPermission, | ||||
viewerIsMember, | viewerIsMember, | ||||
threadFrozenDueToViewerBlock, | threadFrozenDueToViewerBlock, | ||||
threadActualMembers, | threadActualMembers, | ||||
checkIfDefaultMembersAreVoiced, | checkIfDefaultMembersAreVoiced, | ||||
draftKeyFromThreadID, | draftKeyFromThreadID, | ||||
colorIsDark, | colorIsDark, | ||||
} from 'lib/shared/thread-utils'; | } from 'lib/shared/thread-utils'; | ||||
import type { CalendarQuery } from 'lib/types/entry-types'; | import type { CalendarQuery } from 'lib/types/entry-types'; | ||||
import type { LoadingStatus } from 'lib/types/loading-types'; | import type { LoadingStatus } from 'lib/types/loading-types'; | ||||
import type { PhotoPaste } from 'lib/types/media-types'; | import type { PhotoPaste } from 'lib/types/media-types'; | ||||
import { messageTypes } from 'lib/types/message-types'; | import { messageTypes } from 'lib/types/message-types'; | ||||
import type { Dispatch } from 'lib/types/redux-types'; | import type { Dispatch } from 'lib/types/redux-types'; | ||||
import { | import { | ||||
type ThreadInfo, | type ThreadInfo, | ||||
threadPermissions, | threadPermissions, | ||||
type ClientThreadJoinRequest, | type ClientThreadJoinRequest, | ||||
type ThreadJoinPayload, | type ThreadJoinPayload, | ||||
} from 'lib/types/thread-types'; | } from 'lib/types/thread-types'; | ||||
import type { RelativeMemberInfo } from 'lib/types/thread-types'; | |||||
import { type UserInfos } from 'lib/types/user-types'; | import { type UserInfos } from 'lib/types/user-types'; | ||||
import { | import { | ||||
type DispatchActionPromise, | type DispatchActionPromise, | ||||
useServerCall, | useServerCall, | ||||
useDispatchActionPromise, | useDispatchActionPromise, | ||||
} from 'lib/utils/action-utils'; | } from 'lib/utils/action-utils'; | ||||
import Button from '../components/button.react'; | import Button from '../components/button.react'; | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | type Props = { | ||||
+keyboardState: ?KeyboardState, | +keyboardState: ?KeyboardState, | ||||
// Redux dispatch functions | // Redux dispatch functions | ||||
+dispatch: Dispatch, | +dispatch: Dispatch, | ||||
+dispatchActionPromise: DispatchActionPromise, | +dispatchActionPromise: DispatchActionPromise, | ||||
// async functions that hit server APIs | // async functions that hit server APIs | ||||
+joinThread: (request: ClientThreadJoinRequest) => Promise<ThreadJoinPayload>, | +joinThread: (request: ClientThreadJoinRequest) => Promise<ThreadJoinPayload>, | ||||
// withInputState | // withInputState | ||||
+inputState: ?InputState, | +inputState: ?InputState, | ||||
+userSearchIndex: SearchIndex, | |||||
+threadMembers: $ReadOnlyArray<RelativeMemberInfo>, | |||||
}; | }; | ||||
type State = { | type State = { | ||||
+text: string, | +text: string, | ||||
+textEdited: boolean, | +textEdited: boolean, | ||||
+buttonsExpanded: boolean, | +buttonsExpanded: boolean, | ||||
}; | }; | ||||
class ChatInputBar extends React.PureComponent<Props, State> { | class ChatInputBar extends React.PureComponent<Props, State> { | ||||
textInput: ?React.ElementRef<typeof TextInput>; | textInput: ?React.ElementRef<typeof TextInput>; | ||||
▲ Show 20 Lines • Show All 716 Lines • ▼ Show 20 Lines | const isActive = React.useMemo( | ||||
() => props.threadInfo.id === activeThreadSelector(navContext), | () => props.threadInfo.id === activeThreadSelector(navContext), | ||||
[props.threadInfo.id, navContext], | [props.threadInfo.id, navContext], | ||||
); | ); | ||||
const dispatch = useDispatch(); | const dispatch = useDispatch(); | ||||
const dispatchActionPromise = useDispatchActionPromise(); | const dispatchActionPromise = useDispatchActionPromise(); | ||||
const callJoinThread = useServerCall(joinThread); | const callJoinThread = useServerCall(joinThread); | ||||
const userSearchIndex = useSelector(userStoreSearchIndex); | |||||
const threadMembers = useSelector( | |||||
relativeMemberInfoSelectorForMembersOfThread(props.threadInfo.id), | |||||
); | |||||
return ( | return ( | ||||
<ChatInputBar | <ChatInputBar | ||||
{...props} | {...props} | ||||
viewerID={viewerID} | viewerID={viewerID} | ||||
draft={draft} | draft={draft} | ||||
joinThreadLoadingStatus={joinThreadLoadingStatus} | joinThreadLoadingStatus={joinThreadLoadingStatus} | ||||
threadCreationInProgress={threadCreationInProgress} | threadCreationInProgress={threadCreationInProgress} | ||||
calendarQuery={calendarQuery} | calendarQuery={calendarQuery} | ||||
nextLocalID={nextLocalID} | nextLocalID={nextLocalID} | ||||
userInfos={userInfos} | userInfos={userInfos} | ||||
colors={colors} | colors={colors} | ||||
styles={styles} | styles={styles} | ||||
isActive={isActive} | isActive={isActive} | ||||
keyboardState={keyboardState} | keyboardState={keyboardState} | ||||
dispatch={dispatch} | dispatch={dispatch} | ||||
dispatchActionPromise={dispatchActionPromise} | dispatchActionPromise={dispatchActionPromise} | ||||
joinThread={callJoinThread} | joinThread={callJoinThread} | ||||
inputState={inputState} | inputState={inputState} | ||||
userSearchIndex={userSearchIndex} | |||||
threadMembers={threadMembers} | |||||
/> | /> | ||||
); | ); | ||||
} | } | ||||
type DummyChatInputBarProps = { | type DummyChatInputBarProps = { | ||||
...BaseProps, | ...BaseProps, | ||||
+onHeightMeasured: (height: number) => mixed, | +onHeightMeasured: (height: number) => mixed, | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 107 Lines • Show Last 20 Lines |