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

Loading…
Cancel
Save