@@ -32,17 +32,14 @@ import {
32
32
getSavedSettings ,
33
33
} from '../reducers/SettingsReducer' ;
34
34
35
- import {
36
- getSecretKey
37
- } from '../reducers/exportImportReducer'
35
+ import { getSecretKey } from '../reducers/exportImportReducer' ;
38
36
39
37
// Actions
40
38
import * as SettingsActions from '../actions/settings' ;
41
39
import * as ExportImportActions from '../actions/exportImport' ;
42
40
43
41
import { bindActionCreators } from 'redux' ;
44
42
45
-
46
43
// Component
47
44
class Settings extends Component {
48
45
constructor ( props ) {
@@ -55,12 +52,14 @@ class Settings extends Component {
55
52
56
53
componentDidMount ( ) {
57
54
ipc . on ( 'import-file-selected' , ( event , filePath ) => {
58
- this . handleFileUpload ( filePath ) ;
59
- } )
55
+ if ( filePath ) {
56
+ this . handleFileUpload ( filePath ) ;
57
+ }
58
+ } ) ;
60
59
}
61
60
62
61
componentWillUnmount ( ) {
63
- ipc . removeAllListeners ( [ 'import-file-selected' ] )
62
+ ipc . removeAllListeners ( [ 'import-file-selected' ] ) ;
64
63
}
65
64
66
65
// Check if settings have been saved
@@ -86,22 +85,24 @@ class Settings extends Component {
86
85
}
87
86
88
87
handleFileUpload ( filePath ) {
89
- const { secretKey } = this . props
88
+ const { secretKey } = this . props ;
90
89
parseImportFile ( filePath , secretKey , ( err , fileData ) => {
91
90
if ( err ) {
92
91
return ;
93
92
}
94
- this . importData ( fileData )
95
- } )
93
+ this . importData ( fileData ) ;
94
+ } ) ;
96
95
}
97
96
98
97
importData ( fileData ) {
99
- const { importData } = this . props . boundExportImportActionsCreators ;
100
- importData ( fileData )
98
+ if ( fileData ) {
99
+ const { importData } = this . props . boundExportImportActionsCreators ;
100
+ importData ( fileData ) ;
101
+ }
101
102
}
102
103
103
104
selectImportFile ( fileData ) {
104
- ipc . send ( 'open-import-file-dialog' )
105
+ ipc . send ( 'open-import-file-dialog' ) ;
105
106
}
106
107
107
108
// Render Main Content
@@ -148,10 +149,20 @@ class Settings extends Component {
148
149
</ Tabs >
149
150
< TabContent >
150
151
{ this . state . visibleTab === 1 && (
151
- < Profile t = { t } profile = { profile } updateSettings = { updateSettings } setSavable = { this . setSavable } />
152
+ < Profile
153
+ t = { t }
154
+ profile = { profile }
155
+ updateSettings = { updateSettings }
156
+ setSavable = { this . setSavable }
157
+ />
152
158
) }
153
159
{ this . state . visibleTab === 2 && (
154
- < Invoice t = { t } invoice = { invoice } updateSettings = { updateSettings } setSavable = { this . setSavable } />
160
+ < Invoice
161
+ t = { t }
162
+ invoice = { invoice }
163
+ updateSettings = { updateSettings }
164
+ setSavable = { this . setSavable }
165
+ />
155
166
) }
156
167
{ this . state . visibleTab === 3 && (
157
168
< General
@@ -183,23 +194,26 @@ Settings.propTypes = {
183
194
} ) . isRequired ,
184
195
boundExportImportActionsCreators : PropTypes . shape ( {
185
196
exportData : PropTypes . func . isRequired ,
186
- importData : PropTypes . func . isRequired
197
+ importData : PropTypes . func . isRequired ,
187
198
} ) ,
188
199
currentSettings : PropTypes . object . isRequired ,
189
200
savedSettings : PropTypes . object . isRequired ,
190
201
secretKey : PropTypes . string . isRequired ,
191
202
} ;
192
203
193
204
// Map State & Dispatch to Props & Export
194
- const mapDispatchToProps = dispatch => ( {
205
+ const mapDispatchToProps = ( dispatch ) => ( {
195
206
boundActionCreators : bindActionCreators ( SettingsActions , dispatch ) ,
196
- boundExportImportActionsCreators : bindActionCreators ( ExportImportActions , dispatch )
207
+ boundExportImportActionsCreators : bindActionCreators (
208
+ ExportImportActions ,
209
+ dispatch
210
+ ) ,
197
211
} ) ;
198
212
199
- const mapStateToProps = state => ( {
213
+ const mapStateToProps = ( state ) => ( {
200
214
currentSettings : getCurrentSettings ( state ) ,
201
215
savedSettings : getSavedSettings ( state ) ,
202
- secretKey : getSecretKey ( state )
216
+ secretKey : getSecretKey ( state ) ,
203
217
} ) ;
204
218
205
219
export default compose (
0 commit comments