1
1
import React from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
- import { Emitter } from 'event-kit ' ;
3
+ import ItemComponent from './item-component ' ;
4
4
5
5
import { WorkdirContextPoolPropType } from '../prop-types' ;
6
- import { autobind } from '../helpers' ;
7
6
import ChangedFileContainer from '../containers/changed-file-container' ;
8
- import RefHolder from '../models/ref-holder' ;
9
7
10
- export default class ChangedFileItem extends React . Component {
8
+ export default class ChangedFileItem extends ItemComponent {
11
9
static propTypes = {
12
10
workdirContextPool : WorkdirContextPoolPropType . isRequired ,
13
11
@@ -36,15 +34,9 @@ export default class ChangedFileItem extends React.Component {
36
34
}
37
35
38
36
constructor ( props ) {
39
- super ( props ) ;
40
- autobind ( this , 'destroy' ) ;
37
+ super ( props , { } ) ;
41
38
42
- this . emitter = new Emitter ( ) ;
43
- this . isDestroyed = false ;
44
- this . hasTerminatedPendingState = false ;
45
-
46
- this . refEditor = new RefHolder ( ) ;
47
- this . refEditor . observe ( editor => {
39
+ this . refHolder . observe ( editor => {
48
40
this . emitter . emit ( 'did-change-embedded-text-editor' , editor ) ;
49
41
} ) ;
50
42
}
@@ -67,18 +59,6 @@ export default class ChangedFileItem extends React.Component {
67
59
return this . emitter . on ( 'did-terminate-pending-state' , callback ) ;
68
60
}
69
61
70
- destroy ( ) {
71
- /* istanbul ignore else */
72
- if ( ! this . isDestroyed ) {
73
- this . emitter . emit ( 'did-destroy' ) ;
74
- this . isDestroyed = true ;
75
- }
76
- }
77
-
78
- onDidDestroy ( callback ) {
79
- return this . emitter . on ( 'did-destroy' , callback ) ;
80
- }
81
-
82
62
render ( ) {
83
63
const repository = this . props . workdirContextPool . getContext ( this . props . workingDirectory ) . getRepository ( ) ;
84
64
@@ -87,14 +67,14 @@ export default class ChangedFileItem extends React.Component {
87
67
itemType = { this . constructor }
88
68
repository = { repository }
89
69
destroy = { this . destroy }
90
- refEditor = { this . refEditor }
70
+ refEditor = { this . refHolder }
91
71
{ ...this . props }
92
72
/>
93
73
) ;
94
74
}
95
75
96
76
observeEmbeddedTextEditor ( cb ) {
97
- this . refEditor . map ( editor => cb ( editor ) ) ;
77
+ this . refHolder . map ( editor => cb ( editor ) ) ;
98
78
return this . emitter . on ( 'did-change-embedded-text-editor' , cb ) ;
99
79
}
100
80
0 commit comments