Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 59c27a3

Browse files
committed
🔥 @autoBind
1 parent 5bc7c46 commit 59c27a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+239
-318
lines changed

lib/atom-items/issueish-pane-item.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import {Emitter} from 'event-kit';
22

33
import React, {Component} from 'react';
44
import PropTypes from 'prop-types';
5-
import {autobind} from 'core-decorators';
65

6+
import {autobind} from '../helpers';
77
import IssueishPaneItemController from '../controllers/issueish-pane-item-controller';
88
import GithubLoginModel from '../models/github-login-model';
99

@@ -28,6 +28,7 @@ export default class IssueishPaneItem extends Component {
2828

2929
constructor(props) {
3030
super(props);
31+
autobind(this, 'switchToIssueish', 'handleTitleChanged');
3132

3233
this.emitter = new Emitter();
3334
this.title = `${this.props.owner}/${this.props.repo}#${this.props.issueishNumber}`;
@@ -59,12 +60,10 @@ export default class IssueishPaneItem extends Component {
5960
);
6061
}
6162

62-
@autobind
6363
switchToIssueish(owner, repo, issueishNumber) {
6464
this.setState({owner, repo, issueishNumber});
6565
}
6666

67-
@autobind
6867
handleTitleChanged(title) {
6968
if (this.title !== title) {
7069
this.title = title;

lib/atom/atom-text-editor.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22
import PropTypes from 'prop-types';
3-
import {autobind} from 'core-decorators';
43
import {CompositeDisposable} from 'event-kit';
54

65
import RefHolder from '../models/ref-holder';
6+
import {autobind} from '../helpers';
77

88
const editorProps = {
99
autoIndent: PropTypes.bool,
@@ -52,6 +52,7 @@ export default class AtomTextEditor extends React.PureComponent {
5252

5353
constructor(props, context) {
5454
super(props, context);
55+
autobind(this, 'didChange', 'didChangeCursorPosition');
5556

5657
this.subs = new CompositeDisposable();
5758
this.suppressChange = false;
@@ -108,7 +109,6 @@ export default class AtomTextEditor extends React.PureComponent {
108109
}
109110
}
110111

111-
@autobind
112112
didChange() {
113113
if (this.suppressChange) {
114114
return;
@@ -117,7 +117,6 @@ export default class AtomTextEditor extends React.PureComponent {
117117
this.props.didChange(this.getModel());
118118
}
119119

120-
@autobind
121120
didChangeCursorPosition() {
122121
this.props.didChangeCursorPosition(this.getModel());
123122
}

lib/containers/issueish-pane-item-container.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from 'react';
22
import {graphql, createRefetchContainer} from 'react-relay';
33
import PropTypes from 'prop-types';
44
import cx from 'classnames';
5-
import {autobind} from 'core-decorators';
65

76
import IssueTimelineContainer from './issue-timeline-container';
87
import PrTimelineContainer from './pr-timeline-container';
@@ -11,6 +10,7 @@ import Octicon from '../atom/octicon';
1110
import IssueishBadge from '../views/issueish-badge';
1211
import GithubDotcomMarkdown from '../views/github-dotcom-markdown';
1312
import PeriodicRefresher from '../periodic-refresher';
13+
import {autobind} from '../helpers';
1414

1515
const reactionTypeToEmoji = {
1616
THUMBS_UP: '👍',
@@ -62,6 +62,11 @@ export class IssueishPaneItemView extends React.Component {
6262
refreshing: false,
6363
}
6464

65+
constructor(props) {
66+
super(props);
67+
autobind(this, 'handleRefreshClick', 'refresh');
68+
}
69+
6570
componentDidMount() {
6671
this.refresher = new PeriodicRefresher(IssueishPaneItemView, {
6772
interval: () => 5 * 60 * 1000,
@@ -141,13 +146,11 @@ export class IssueishPaneItemView extends React.Component {
141146
);
142147
}
143148

144-
@autobind
145149
handleRefreshClick(e) {
146150
e.preventDefault();
147151
this.refresher.refreshNow(true);
148152
}
149153

150-
@autobind
151154
refresh() {
152155
if (this.state.refreshing) {
153156
return;

lib/containers/pr-info-container.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import React from 'react';
22
import {graphql, createRefetchContainer} from 'react-relay';
33
import PropTypes from 'prop-types';
44
import cx from 'classnames';
5-
import {autobind} from 'core-decorators';
5+
import tinycolor from 'tinycolor2';
66

77
import Octicon from '../atom/octicon';
88
import IssueishBadge from '../views/issueish-badge';
99
import PeriodicRefresher from '../periodic-refresher';
10-
import tinycolor from 'tinycolor2';
11-
1210
import PrStatusesContainer from './pr-statuses-container';
11+
import {autobind} from '../helpers';
1312

1413
const reactionTypeToEmoji = {
1514
THUMBS_UP: '👍',
@@ -57,8 +56,13 @@ export class PrInfo extends React.Component {
5756
}).isRequired,
5857
}
5958

60-
state = {
61-
refreshing: false,
59+
constructor(props) {
60+
super(props);
61+
autobind(this, 'handleRefreshClick', 'refresh', 'handleClickPrLink', 'handleUnpinClick');
62+
63+
this.state = {
64+
refreshing: false,
65+
};
6266
}
6367

6468
componentDidMount() {
@@ -75,13 +79,11 @@ export class PrInfo extends React.Component {
7579
this.refresher.destroy();
7680
}
7781

78-
@autobind
7982
handleRefreshClick(e) {
8083
e.preventDefault();
8184
this.refresher.refreshNow(true);
8285
}
8386

84-
@autobind
8587
refresh() {
8688
if (this.state.refreshing) {
8789
return;
@@ -172,7 +174,6 @@ export class PrInfo extends React.Component {
172174
);
173175
}
174176

175-
@autobind
176177
handleClickPrLink(event) {
177178
event.nativeEvent.preventDefault();
178179
event.nativeEvent.stopPropagation();
@@ -181,7 +182,6 @@ export class PrInfo extends React.Component {
181182
atom.workspace.open(`atom-github://issueish/https%3A%2F%2Fapi.github.com/${repo.owner.login}/${repo.name}/${pr.number}`);
182183
}
183184

184-
@autobind
185185
handleUnpinClick(event) {
186186
event.preventDefault();
187187
this.props.onUnpinPr && this.props.onUnpinPr();

lib/containers/pr-selection-by-branch-container.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import React from 'react';
22
import {graphql, createFragmentContainer} from 'react-relay';
33
import PropTypes from 'prop-types';
4-
import {autobind} from 'core-decorators';
54

65
import PrInfoContainer from './pr-info-container';
76
import PrUrlInputBox from '../views/pr-url-input-box';
87
import Octicon from '../atom/octicon';
98
import {RemotePropType, BranchSetPropType} from '../prop-types';
9+
import {autobind} from '../helpers';
1010

1111
export class PrSelectionByBranch extends React.Component {
1212
static propTypes = {
@@ -44,6 +44,7 @@ export class PrSelectionByBranch extends React.Component {
4444

4545
constructor(props, context) {
4646
super(props, context);
47+
autobind(this, 'renderPrItem', 'toggleInputBoxVisibility', 'setPr', 'selectPullRequest');
4748
this.state = {displayInputBox: false};
4849
}
4950

@@ -222,7 +223,6 @@ export class PrSelectionByBranch extends React.Component {
222223
);
223224
}
224225

225-
@autobind
226226
renderPrItem({node}) {
227227
return (
228228
<li key={node.id} onClick={e => this.selectPullRequest(e, node)}>
@@ -231,17 +231,14 @@ export class PrSelectionByBranch extends React.Component {
231231
);
232232
}
233233

234-
@autobind
235234
toggleInputBoxVisibility() {
236235
this.setState({displayInputBox: !this.state.displayInputBox});
237236
}
238237

239-
@autobind
240238
setPr(prLink) {
241239
this.props.onSelectPr(prLink);
242240
}
243241

244-
@autobind
245242
selectPullRequest(event, node) {
246243
event.preventDefault();
247244
this.setPr(node.url);

lib/containers/pr-statuses-container.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React from 'react';
22
import {createRefetchContainer, graphql} from 'react-relay';
33
import PropTypes from 'prop-types';
4-
import {autobind} from 'core-decorators';
54

6-
import {toSentence} from '../helpers';
5+
import {toSentence, autobind} from '../helpers';
76
import PrStatusContextContainer from './pr-status-context-container';
87
import Octicon from '../atom/octicon';
98
import DonutChart from '../views/donut-chart';
@@ -83,6 +82,11 @@ export class PrStatuses extends React.Component {
8382
static PENDING_REFRESH_TIMEOUT = 30 * 1000
8483
static MINIMUM_REFRESH_INTERVAL = 15 * 1000
8584

85+
constructor(props) {
86+
super(props);
87+
autobind(this, 'refresh');
88+
}
89+
8690
componentDidMount() {
8791
this.refresher = new PeriodicRefresher(PrStatuses, {
8892
interval: () => {
@@ -103,7 +107,6 @@ export class PrStatuses extends React.Component {
103107
this.refresher.destroy();
104108
}
105109

106-
@autobind
107110
refresh() {
108111
this.props.relay.refetch({
109112
id: this.props.pullRequest.id,

lib/controllers/commit-controller.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import path from 'path';
33
import React from 'react';
44
import ReactDom from 'react-dom';
55
import PropTypes from 'prop-types';
6-
import {autobind} from 'core-decorators';
76
import {CompositeDisposable} from 'event-kit';
87
import fs from 'fs-extra';
98

109
import CommitView from '../views/commit-view';
1110
import {AuthorPropType} from '../prop-types';
11+
import {autobind} from '../helpers';
1212

1313
export const COMMIT_GRAMMAR_SCOPE = 'text.git-commit';
1414

@@ -41,6 +41,7 @@ export default class CommitController extends React.Component {
4141

4242
constructor(props, context) {
4343
super(props, context);
44+
autobind(this, 'commit', 'handleMessageChange', 'toggleExpandedCommitMessageEditor', 'grammarAdded');
4445

4546
this.subscriptions = new CompositeDisposable();
4647
this.refCommitView = null;
@@ -121,7 +122,6 @@ export default class CommitController extends React.Component {
121122
this.subscriptions.dispose();
122123
}
123124

124-
@autobind
125125
commit(message, coAuthors = [], amend) {
126126
let msg;
127127
if (this.isCommitMessageEditorExpanded()) {
@@ -149,7 +149,6 @@ export default class CommitController extends React.Component {
149149
return path.join(this.props.repository.getGitDirectoryPath(), 'ATOM_COMMIT_EDITMSG');
150150
}
151151

152-
@autobind
153152
handleMessageChange(newMessage) {
154153
if (!this.props.repository.isPresent()) {
155154
return;
@@ -164,7 +163,6 @@ export default class CommitController extends React.Component {
164163
return this.props.workspace.getTextEditors().filter(editor => editor.getPath() === this.getCommitMessagePath());
165164
}
166165

167-
@autobind
168166
async toggleExpandedCommitMessageEditor(messageFromBox) {
169167
if (this.isCommitMessageEditorExpanded()) {
170168
if (this.commitMessageEditorIsInForeground()) {
@@ -226,7 +224,6 @@ export default class CommitController extends React.Component {
226224
}
227225
}
228226

229-
@autobind
230227
grammarAdded(grammar) {
231228
if (grammar.scopeName !== COMMIT_GRAMMAR_SCOPE) { return; }
232229

lib/controllers/conflict-controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
33
import {remote} from 'electron';
44
const {Menu, MenuItem} = remote;
55

6-
import {autobind} from 'core-decorators';
6+
import {autobind} from '../helpers';
77
import {OURS, BASE, THEIRS} from '../models/conflicts/source';
88
import Decoration from '../atom/decoration';
99
import Octicon from '../atom/octicon';
@@ -23,6 +23,7 @@ export default class ConflictController extends React.Component {
2323

2424
constructor(props, context) {
2525
super(props, context);
26+
autobind(this, 'showResolveMenu');
2627

2728
this.state = {
2829
chosenSide: this.props.conflict.getChosenSide(),
@@ -42,7 +43,6 @@ export default class ConflictController extends React.Component {
4243
side.isBannerModified() && side.revertBanner();
4344
}
4445

45-
@autobind
4646
showResolveMenu(event) {
4747
event.preventDefault();
4848

lib/controllers/editor-conflict-controller.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import {CompositeDisposable} from 'event-kit';
22
import React from 'react';
33
import PropTypes from 'prop-types';
4-
import {autobind} from 'core-decorators';
54
import compareSets from 'compare-sets';
65

76
import Commands, {Command} from '../atom/commands';
87
import Conflict from '../models/conflicts/conflict';
98
import ConflictController from './conflict-controller';
109
import {OURS, THEIRS, BASE} from '../models/conflicts/source';
10+
import {autobind} from '../helpers';
1111

1212
/**
1313
* Render a `ConflictController` for each conflict marker within an open TextEditor.
@@ -27,6 +27,7 @@ export default class EditorConflictController extends React.Component {
2727

2828
constructor(props, context) {
2929
super(props, context);
30+
autobind(this, 'resolveAsCurrent', 'revertConflictModifications', 'dismissCurrent');
3031

3132
// this.layer = props.editor.addMarkerLayer({
3233
// maintainHistory: true,
@@ -147,7 +148,6 @@ export default class EditorConflictController extends React.Component {
147148
};
148149
}
149150

150-
@autobind
151151
resolveAsCurrent() {
152152
this.getCurrentConflicts().forEach(match => {
153153
if (match.sides.size === 1) {
@@ -157,7 +157,6 @@ export default class EditorConflictController extends React.Component {
157157
});
158158
}
159159

160-
@autobind
161160
revertConflictModifications() {
162161
this.getCurrentConflicts().forEach(match => {
163162
match.sides.forEach(side => {
@@ -167,7 +166,6 @@ export default class EditorConflictController extends React.Component {
167166
});
168167
}
169168

170-
@autobind
171169
dismissCurrent() {
172170
this.dismissConflicts(this.getCurrentConflicts().map(match => match.conflict));
173171
}

0 commit comments

Comments
 (0)