autobind class with a lot of ...bind(this)

pull/1534/head
Audric Ackermann 4 years ago
parent 24d33c7900
commit 099c9a6f8c
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -27,7 +27,6 @@ sendSyncMessageOnly to fix
indexedDB
initializeAttachmentMetadata=>
schemaVersion for messages to put as what needs to be set
run_migration

@ -118,10 +118,7 @@ class SessionSeedModalInner extends React.Component<Props, State> {
const bgColor = '#FFFFFF';
const fgColor = '#1B1B1B';
const hexEncodedSeed = window.mnemonic.mn_decode(
this.state.recoveryPhrase,
'english'
);
const hexEncodedSeed = mn_decode(this.state.recoveryPhrase, 'english');
return (
<>

@ -30,6 +30,7 @@ import { DefaultTheme } from 'styled-components';
import { ConversationController } from '../../../session/conversations';
import { ConversationType } from '../../../state/ducks/conversations';
import { SessionMemberListItem } from '../SessionMemberListItem';
import autoBind from 'auto-bind';
export interface ReplyingToMessageProps {
convoId: string;
@ -142,41 +143,8 @@ export class SessionCompositionBox extends React.Component<Props, State> {
// Emojis
this.emojiPanel = null;
autoBind(this);
this.toggleEmojiPanel = debounce(this.toggleEmojiPanel.bind(this), 100);
this.hideEmojiPanel = this.hideEmojiPanel.bind(this);
this.onEmojiClick = this.onEmojiClick.bind(this);
this.handleClick = this.handleClick.bind(this);
this.renderRecordingView = this.renderRecordingView.bind(this);
this.renderCompositionView = this.renderCompositionView.bind(this);
this.renderTextArea = this.renderTextArea.bind(this);
this.renderQuotedMessage = this.renderQuotedMessage.bind(this);
this.renderStagedLinkPreview = this.renderStagedLinkPreview.bind(this);
this.renderAttachmentsStaged = this.renderAttachmentsStaged.bind(this);
// Recording view functions
this.sendVoiceMessage = this.sendVoiceMessage.bind(this);
this.onLoadVoiceNoteView = this.onLoadVoiceNoteView.bind(this);
this.onExitVoiceNoteView = this.onExitVoiceNoteView.bind(this);
// Attachments
this.onChoseAttachment = this.onChoseAttachment.bind(this);
this.onChooseAttachment = this.onChooseAttachment.bind(this);
this.onClickAttachment = this.onClickAttachment.bind(this);
this.renderCaptionEditor = this.renderCaptionEditor.bind(this);
this.abortLinkPreviewFetch = this.abortLinkPreviewFetch.bind(this);
// On Sending
this.onSendMessage = this.onSendMessage.bind(this);
// Events
this.onKeyDown = this.onKeyDown.bind(this);
this.onKeyUp = this.onKeyUp.bind(this);
this.onChange = this.onChange.bind(this);
this.focusCompositionBox = this.focusCompositionBox.bind(this);
this.fetchUsersForGroup = this.fetchUsersForGroup.bind(this);
}
public componentDidMount() {

@ -35,6 +35,7 @@ import {
getMessageById,
getPubkeysInPublicConversation,
} from '../../../data/data';
import autoBind from 'auto-bind';
interface State {
// Message sending progress
@ -106,47 +107,7 @@ export class SessionConversation extends React.Component<Props, State> {
this.messageContainerRef = React.createRef();
this.dragCounter = 0;
// Group settings panel
this.toggleRightPanel = this.toggleRightPanel.bind(this);
this.getRightPanelProps = this.getRightPanelProps.bind(this);
// Recording view
this.onLoadVoiceNoteView = this.onLoadVoiceNoteView.bind(this);
this.onExitVoiceNoteView = this.onExitVoiceNoteView.bind(this);
// Messages
this.loadInitialMessages = this.loadInitialMessages.bind(this);
this.selectMessage = this.selectMessage.bind(this);
this.resetSelection = this.resetSelection.bind(this);
this.updateSendingProgress = this.updateSendingProgress.bind(this);
this.resetSendingProgress = this.resetSendingProgress.bind(this);
this.onMessageSending = this.onMessageSending.bind(this);
this.onMessageSuccess = this.onMessageSuccess.bind(this);
this.onMessageFailure = this.onMessageFailure.bind(this);
this.deleteSelectedMessages = this.deleteSelectedMessages.bind(this);
this.replyToMessage = this.replyToMessage.bind(this);
this.showMessageDetails = this.showMessageDetails.bind(this);
this.deleteMessage = this.deleteMessage.bind(this);
this.onClickAttachment = this.onClickAttachment.bind(this);
this.downloadAttachment = this.downloadAttachment.bind(this);
// Keyboard navigation
this.onKeyDown = this.onKeyDown.bind(this);
this.renderLightBox = this.renderLightBox.bind(this);
// attachments
this.clearAttachments = this.clearAttachments.bind(this);
this.addAttachments = this.addAttachments.bind(this);
this.removeAttachment = this.removeAttachment.bind(this);
this.onChoseAttachments = this.onChoseAttachments.bind(this);
this.handleDragIn = this.handleDragIn.bind(this);
this.handleDragOut = this.handleDragOut.bind(this);
this.handleDrag = this.handleDrag.bind(this);
this.handleDrop = this.handleDrop.bind(this);
this.updateMemberList = this.updateMemberList.bind(this);
autoBind(this);
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

@ -18,6 +18,7 @@ import { ConversationController } from '../../../session/conversations';
import { MessageModel } from '../../../models/message';
import { MessageRegularProps } from '../../../models/messageType';
import { getMessagesBySentAt } from '../../../data/data';
import autoBind from 'auto-bind';
interface State {
showScrollButton: boolean;
@ -59,13 +60,7 @@ export class SessionMessagesList extends React.Component<Props, State> {
this.state = {
showScrollButton: false,
};
this.renderMessage = this.renderMessage.bind(this);
this.handleScroll = this.handleScroll.bind(this);
this.scrollToUnread = this.scrollToUnread.bind(this);
this.scrollToBottom = this.scrollToBottom.bind(this);
this.scrollToQuoteMessage = this.scrollToQuoteMessage.bind(this);
this.getScrollOffsetBottomPx = this.getScrollOffsetBottomPx.bind(this);
this.displayUnreadBannerIndex = this.displayUnreadBannerIndex.bind(this);
autoBind(this);
this.messageContainerRef = this.props.messageContainerRef;
this.ignoreScrollEvents = true;

@ -13,6 +13,7 @@ import {
import { Constants } from '../../../session';
import { ToastUtils } from '../../../session/utils';
import { DefaultTheme, withTheme } from 'styled-components';
import autoBind from 'auto-bind';
interface Props {
onExitVoiceNoteView: any;
@ -64,33 +65,13 @@ class SessionRecordingInner extends React.Component<Props, State> {
constructor(props: Props) {
super(props);
// Mouse interaction
this.handleHoverActions = this.handleHoverActions.bind(this);
this.handleUnhoverActions = this.handleUnhoverActions.bind(this);
// Component actions
this.playAudio = this.playAudio.bind(this);
this.pauseAudio = this.pauseAudio.bind(this);
this.stopRecording = this.stopRecording.bind(this);
// Voice message actions
this.onSendVoiceMessage = this.onSendVoiceMessage.bind(this);
this.onDeleteVoiceMessage = this.onDeleteVoiceMessage.bind(this);
// Stream monitors
this.timerUpdate = this.timerUpdate.bind(this);
this.onRecordingStream = this.onRecordingStream.bind(this);
this.stopRecordingStream = this.stopRecordingStream.bind(this);
autoBind(this);
// Refs
this.visualisationRef = React.createRef();
this.visualisationCanvas = React.createRef();
this.playbackCanvas = React.createRef();
// Listeners
this.onKeyDown = this.onKeyDown.bind(this);
this.updateCanvasDimensions = this.updateCanvasDimensions.bind(this);
const now = getTimestamp();
const updateTimerInterval = global.setInterval(this.timerUpdate, 500);

@ -669,8 +669,6 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
}
public async getPropsForMessageDetail() {
const newIdentity = window.i18n('newIdentity');
// We include numbers we didn't successfully send to so we can display errors.
// Older messages don't have the recipients included on the message, so we fall
// back to the conversation's current recipients

Loading…
Cancel
Save