File input prep

pull/1102/head
Vincent 5 years ago
parent 5d11ef1457
commit 3055e2345c

@ -50,7 +50,7 @@ $composition-container-height: 60px;
align-items: center;
background-color: $session-shade-4;
padding: 0px $session-margin-md;
min-height: $composition-container-height;
min-height: min-content;
& > .session-icon-button {
margin-right: $session-margin-sm;

@ -6,7 +6,7 @@ import { SessionEmojiPanel } from './SessionEmojiPanel';
interface Props {
placeholder?: string;
onSendMessage: any;
sendMessage: any;
}
interface State {
@ -16,6 +16,7 @@ interface State {
export class SessionCompositionBox extends React.Component<Props, State> {
private textarea: React.RefObject<HTMLTextAreaElement>;
private fileInput: React.RefObject<HTMLInputElement>;
constructor(props: any) {
super(props);
@ -26,6 +27,11 @@ export class SessionCompositionBox extends React.Component<Props, State> {
};
this.textarea = React.createRef();
this.fileInput = React.createRef();
this.onKeyUp = this.onKeyUp.bind(this);
this.onChooseAttachment = this.onChooseAttachment.bind(this);
this.toggleEmojiPanel = this.toggleEmojiPanel.bind(this);
}
@ -38,7 +44,14 @@ export class SessionCompositionBox extends React.Component<Props, State> {
<SessionIconButton
iconType={SessionIconType.CirclePlus}
iconSize={SessionIconSize.Large}
onClick={this.onChooseAttachment}
/>
<input
ref={this.fileInput}
type='file'
/>
<SessionIconButton
iconType={SessionIconType.Microphone}
iconSize={SessionIconSize.Large}
@ -47,10 +60,11 @@ export class SessionCompositionBox extends React.Component<Props, State> {
<div className="send-message-input">
<TextareaAutosize
rows={1}
maxRows={6}
maxRows={3}
ref={this.textarea}
placeholder={placeholder}
maxLength={window.CONSTANTS.MAX_MESSAGE_BODY_LENGTH}
onKeyUp={this.onKeyUp}
/>
</div>
@ -78,4 +92,41 @@ export class SessionCompositionBox extends React.Component<Props, State> {
showEmojiPanel: !this.state.showEmojiPanel,
});
}
private onChooseAttachment() {
this.fileInput.current?.click();
}
private onChoseAttachment() {
}
private onKeyUp(event: any) {
console.log(`[vince][msg] Event: `, event);
console.log(`[vince][msg] Key `, event.key);
console.log(`[vince][msg] KeyCode `, event.keyCode);
console.log(`[vince][msg] AltKey `, event.altKey);
console.log(`[vince][msg] Ctrl: `, event.ctrlKey);
console.log(`[vince][msg] Shift: `, event.shiftKey);
if (event.key === 'Enter' && !event.shiftKey) {
// If shift, newline. Else send message.
event.preventDefault();
// FIXME VINCE: Get emoiji, attachments, etc
const messageBody = this.textarea.current?.value;
const attachments = this.fileInput.current?.value;
// this.props.sendMessage(
// );
}
}
}

@ -36,7 +36,6 @@ export class SessionConversation extends React.Component<any, State> {
super(props);
const conversationKey = this.props.conversations.selectedConversation;
const conversation = this.props.conversations.conversationLookup[conversationKey];
const unreadCount = conversation.unreadCount;
@ -74,8 +73,6 @@ export class SessionConversation extends React.Component<any, State> {
doneInitialScroll: true,
});
}, 100);
console.log(`[vince][info] HeaderProps:`, this.getHeaderProps());
}
public componentDidUpdate(){
@ -97,21 +94,18 @@ export class SessionConversation extends React.Component<any, State> {
render() {
console.log(`[vince][info] Props`, this.props);
console.log(`[vince][info] Unread: `, this.state.unreadCount);
console.log(`[vince][info] Messages:`, this.state.messages);
// const headerProps = this.props.getHeaderProps;
const { messages, conversationKey, doneInitialScroll } = this.state;
const loading = !doneInitialScroll || messages.length === 0;
const conversation = this.props.conversations.conversationLookup[conversationKey];
const conversationModel = window.getConversationByKey(conversationKey);
const isRss = conversation.isRss;
return (
<div className="conversation-item">
<div className="conversation-header">
{this.renderHeader(conversation)}
{this.renderHeader()}
</div>
<SessionProgress
@ -138,7 +132,7 @@ export class SessionConversation extends React.Component<any, State> {
{ !isRss && (
<SessionCompositionBox
onSendMessage={() => null}
sendMessage={conversationModel.sendMessage}
/>
)}
@ -178,49 +172,51 @@ export class SessionConversation extends React.Component<any, State> {
}
public renderHeader(conversation: any) {
public renderHeader() {
const headerProps = this.getHeaderProps();
return (
<ConversationHeader
id={conversation.cid}
phoneNumber={conversation.id}
isVerified={true}
isMe={false}
isFriend={true}
id={headerProps.id}
phoneNumber={headerProps.phoneNumber}
isVerified={headerProps.isVerified}
isMe={headerProps.isMe}
isFriend={headerProps.isFriend}
i18n={window.i18n}
isGroup={false}
isArchived={false}
isPublic={false}
isRss={false}
amMod={false}
members={[]}
showBackButton={false}
timerOptions={[]}
isBlocked={false}
hasNickname={false}
isFriendRequestPending={false}
isOnline={true}
selectedMessages={null}
onSetDisappearingMessages={() => null}
onDeleteMessages={() => null}
onDeleteContact={() => null}
onResetSession={() => null}
onCloseOverlay={() => null}
onDeleteSelectedMessages={() => null}
onArchive={() => null}
onMoveToInbox={() => null}
onShowSafetyNumber={() => null}
onShowAllMedia={() => null}
onShowGroupMembers={() => null}
onGoBack={() => null}
onBlockUser={() => null}
onUnblockUser={() => null}
onClearNickname={() => null}
onChangeNickname={() => null}
onCopyPublicKey={() => null}
onLeaveGroup={() => null}
onAddModerators={() => null}
onRemoveModerators={() => null}
onInviteFriends={() => null}
isGroup={headerProps.isGroup}
isArchived={headerProps.isArchived}
isPublic={headerProps.isPublic}
isRss={headerProps.isRss}
amMod={headerProps.amMod}
members={headerProps.members}
showBackButton={headerProps.showBackButton}
timerOptions={headerProps.timerOptions}
isBlocked={headerProps.isBlocked}
hasNickname={headerProps.hasNickname}
isFriendRequestPending={headerProps.isFriendRequestPending}
isOnline={headerProps.isOnline}
selectedMessages={headerProps.selectedMessages}
onSetDisappearingMessages={headerProps.onSetDisappearingMessages}
onDeleteMessages={headerProps.onDeleteMessages}
onDeleteContact={headerProps.onDeleteContact}
onResetSession={headerProps.onResetSession}
onCloseOverlay={headerProps.onCloseOverlay}
onDeleteSelectedMessages={headerProps.onDeleteSelectedMessages}
onArchive={headerProps.onArchive}
onMoveToInbox={headerProps.onMoveToInbox}
onShowSafetyNumber={headerProps.onShowSafetyNumber}
onShowAllMedia={headerProps.onShowAllMedia}
onShowGroupMembers={headerProps.onShowGroupMembers}
onGoBack={headerProps.onGoBack}
onBlockUser={headerProps.onBlockUser}
onUnblockUser={headerProps.onUnblockUser}
onClearNickname={headerProps.onClearNickname}
onChangeNickname={headerProps.onChangeNickname}
onCopyPublicKey={headerProps.onCopyPublicKey}
onLeaveGroup={headerProps.onLeaveGroup}
onAddModerators={headerProps.onAddModerators}
onRemoveModerators={headerProps.onRemoveModerators}
onInviteFriends={headerProps.onInviteFriends}
/>
);
}
@ -407,7 +403,7 @@ export class SessionConversation extends React.Component<any, State> {
topUnreadMessage?.scrollIntoView();
}
public scrollToBottom(instant = false) {
public scrollToBottom() {
// FIXME VINCE: Smooth scrolling that isn't slow@!
// this.messagesEndRef.current?.scrollIntoView(
// { behavior: firstLoad ? 'auto' : 'smooth' }
@ -418,12 +414,8 @@ export class SessionConversation extends React.Component<any, State> {
}
public getHeaderProps() {
const conversationKey = this.props.conversations.selectedConversation;
const {conversationKey} = this.state;
const conversation = window.getConversationByKey(conversationKey);
console.log(`[vince][info] Key:`, conversationKey);
console.log(`[vince][info] Conversation`, conversation);
console.log(`[vince] Manual: `, );
const expireTimer = conversation.get('expireTimer');
const expirationSettingName = expireTimer

Loading…
Cancel
Save