Skip to content

Commit d9145b6

Browse files
committed
fix: use logger in postFile, refactor postFile
1 parent d308f36 commit d9145b6

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

public/app/listeners/postFile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const postFile = mainWindow => (event, payload = {}) => {
2828
// send back the resource
2929
mainWindow.webContents.send(POST_FILE_CHANNEL, newPayload);
3030
} catch (e) {
31-
console.error(e);
31+
logger.error(e);
3232
mainWindow.webContents.send(POST_FILE_CHANNEL, ERROR_GENERAL);
3333
}
3434
};

src/actions/file.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { ERROR_POSTING_FILE_MESSAGE } from '../config/messages';
77
export const postFile = async (
88
{ userId, appInstanceId, spaceId, subSpaceId, format, data, type } = {},
99
callback
10-
) => () => {
10+
) => {
1111
try {
1212
window.ipcRenderer.send(POST_FILE_CHANNEL, {
1313
userId,
@@ -36,6 +36,10 @@ export const postFile = async (
3636
}
3737
});
3838
} catch (err) {
39-
console.error(err);
39+
callback({
40+
appInstanceId,
41+
type: POST_FILE_FAILED,
42+
payload: ERROR_POSTING_FILE_MESSAGE,
43+
});
4044
}
4145
};

src/components/phase/PhaseApp.js

+1-4
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class PhaseApp extends Component {
5454
folder: PropTypes.string.isRequired,
5555
dispatchGetAppInstance: PropTypes.func.isRequired,
5656
dispatchPostAction: PropTypes.func.isRequired,
57-
dispatchPostFile: PropTypes.func.isRequired,
5857
id: PropTypes.string.isRequired,
5958
phaseId: PropTypes.string.isRequired,
6059
spaceId: PropTypes.string.isRequired,
@@ -119,7 +118,6 @@ class PhaseApp extends Component {
119118
try {
120119
const {
121120
dispatchGetAppInstance,
122-
dispatchPostFile,
123121
appInstance,
124122
dispatchPostAction,
125123
user,
@@ -166,7 +164,7 @@ class PhaseApp extends Component {
166164
}
167165
case POST_FILE: {
168166
if (isSpaceSaved) {
169-
return dispatchPostFile(payload, this.postMessage);
167+
return postFile(payload, this.postMessage);
170168
}
171169
break;
172170
}
@@ -341,7 +339,6 @@ const mapStateToProps = ({ authentication, Space }) => ({
341339
const mapDispatchToProps = {
342340
dispatchGetAppInstance: getAppInstance,
343341
dispatchPostAction: postAction,
344-
dispatchPostFile: postFile,
345342
};
346343

347344
const ConnectedComponent = connect(

0 commit comments

Comments
 (0)