Cleanup wrt tslint

pull/1102/head
Vincent 6 years ago
parent 6cda163b27
commit 214be7a298

@ -136,6 +136,7 @@ $composition-container-height: 60px;
flex-grow: 1;
flex-direction: column;
position: relative;
height: 0px;
&--blocking-overlay {
background-color: rgba(0, 0, 0, 0.8);

@ -1,3 +1,5 @@
// tslint:disable: no-backbone-get-set-outside-model
import React from 'react';
import classNames from 'classnames';
@ -14,6 +16,7 @@ import { getTimestamp } from './SessionConversationManager';
import { SessionScrollButton } from '../SessionScrollButton';
import { SessionGroupSettings } from './SessionGroupSettings';
interface State {
conversationKey: string;
sendingProgress: number;
@ -38,8 +41,8 @@ interface State {
}
export class SessionConversation extends React.Component<any, State> {
private messagesEndRef: React.RefObject<HTMLDivElement>;
private messageContainerRef: React.RefObject<HTMLDivElement>;
private readonly messagesEndRef: React.RefObject<HTMLDivElement>;
private readonly messageContainerRef: React.RefObject<HTMLDivElement>;
constructor(props: any) {
super(props);
@ -116,7 +119,7 @@ export class SessionConversation extends React.Component<any, State> {
doneInitialScroll: true,
});
}, 100);
});
}).catch();
this.updateReadMessages();
}
@ -163,6 +166,7 @@ export class SessionConversation extends React.Component<any, State> {
className={classNames('conversation-item__content', selectionMode && 'selection-mode')}
tabIndex={0}
onKeyDown={this.onKeyDown}
role="navigation"
>
<div className="conversation-header">
{this.renderHeader()}
@ -178,7 +182,7 @@ export class SessionConversation extends React.Component<any, State> {
<div className="messages-wrapper">
{ loading && (
<div className="messages-container__loading"></div>
<div className="messages-container__loading"/>
)}
<div
@ -192,7 +196,7 @@ export class SessionConversation extends React.Component<any, State> {
<SessionScrollButton show={showScrollButton} onClick={this.scrollToBottom}/>
{ showRecordingView && (
<div className="messages-wrapper--blocking-overlay"></div>
<div className="messages-wrapper--blocking-overlay"/>
)}
</div>
@ -311,7 +315,9 @@ export class SessionConversation extends React.Component<any, State> {
messageProps.i18n = window.i18n;
messageProps.selected = selected;
messageProps.firstMessageOfSeries = firstMessageOfSeries;
messageProps.onSelectMessage = (messageId: string) => this.selectMessage(messageId);
messageProps.onSelectMessage = (messageId: string) => {
this.selectMessage(messageId);
}
messageProps.quote = quoteProps || undefined;
return (
@ -328,7 +334,7 @@ export class SessionConversation extends React.Component<any, State> {
);
}
public renderFriendRequest(friendRequestProps: any){
public renderFriendRequest(friendRequestProps: any) {
friendRequestProps.i18n = window.i18n;
return (
@ -360,7 +366,7 @@ export class SessionConversation extends React.Component<any, State> {
return { newTopMessage: undefined, previousTopMessage: undefined };
}
let msgCount = numMessages || window.CONSTANTS.DEFAULT_MESSAGE_FETCH_COUNT + this.state.unreadCount;
let msgCount = numMessages || Number(window.CONSTANTS.DEFAULT_MESSAGE_FETCH_COUNT) + this.state.unreadCount;
msgCount = msgCount > window.CONSTANTS.MAX_MESSAGE_FETCH_COUNT
? window.CONSTANTS.MAX_MESSAGE_FETCH_COUNT
: msgCount;
@ -447,7 +453,9 @@ export class SessionConversation extends React.Component<any, State> {
onDeleteSelectedMessages: () => conversation.deleteSelectedMessages(),
onCloseOverlay: () => conversation.resetMessageSelection(),
onDeleteContact: () => conversation.deleteContact(),
onResetSession: () => this.resetSelection(),
onResetSession: () => {
this.resetSelection();
},
// These are view only and don't update the Conversation model, so they
// need a manual update call.
@ -517,7 +525,7 @@ export class SessionConversation extends React.Component<any, State> {
}
},
};
};
}
public getGroupSettingsProps() {
const { conversationKey } = this.state;
@ -646,7 +654,9 @@ export class SessionConversation extends React.Component<any, State> {
public findNewestVisibleUnread() {
const messageContainer = this.messageContainerRef.current;
if (!messageContainer) return null;
if (!messageContainer) {
return null;
}
const { messages, unreadCount } = this.state;
const { length } = messages;
@ -736,7 +746,9 @@ export class SessionConversation extends React.Component<any, State> {
// Scrolled to bottom
const isScrolledToBottom = scrollOffsetPc === 0;
if (isScrolledToBottom) console.log(`[scroll] Scrolled to bottom`);
if (isScrolledToBottom) {
console.log(`[scroll] Scrolled to bottom`);
}
// Mark messages read
this.updateReadMessages();
@ -763,7 +775,9 @@ export class SessionConversation extends React.Component<any, State> {
const { messages, unreadCount } = this.state;
const message = messages[(messages.length - 1) - unreadCount];
if(message) this.scrollToMessage(message.id);
if (message) {
this.scrollToMessage(message.id);
}
}
public scrollToMessage(messageId: string) {
@ -778,7 +792,9 @@ export class SessionConversation extends React.Component<any, State> {
// );
const messageContainer = this.messageContainerRef.current;
if (!messageContainer) return;
if (!messageContainer) {
return;
}
messageContainer.scrollTop = messageContainer.scrollHeight - messageContainer.clientHeight;
}
@ -819,7 +835,9 @@ export class SessionConversation extends React.Component<any, State> {
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
private onKeyDown(event: any) {
const messageContainer = this.messageContainerRef.current;
if (!messageContainer) return;
if (!messageContainer) {
return;
}
const selectionMode = !!this.state.selectedMessages.length;
const recordingMode = this.state.showRecordingView;
@ -838,7 +856,9 @@ export class SessionConversation extends React.Component<any, State> {
switch(event.key){
case 'Escape':
if (selectionMode) this.resetSelection();
if (selectionMode) {
this.resetSelection();
}
break;
// Scrolling
@ -855,11 +875,7 @@ export class SessionConversation extends React.Component<any, State> {
messageContainer.scrollBy(0, pageScrollPx);
break;
default:
break;
}
}
}

Loading…
Cancel
Save