Skip to content

Commit

Permalink
fix: use logger in postFile, refactor postFile
Browse files Browse the repository at this point in the history
  • Loading branch information
pyphilia committed Aug 31, 2020
1 parent d308f36 commit d9145b6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion public/app/listeners/postFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const postFile = mainWindow => (event, payload = {}) => {
// send back the resource
mainWindow.webContents.send(POST_FILE_CHANNEL, newPayload);
} catch (e) {
console.error(e);
logger.error(e);
mainWindow.webContents.send(POST_FILE_CHANNEL, ERROR_GENERAL);
}
};
Expand Down
8 changes: 6 additions & 2 deletions src/actions/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ERROR_POSTING_FILE_MESSAGE } from '../config/messages';
export const postFile = async (
{ userId, appInstanceId, spaceId, subSpaceId, format, data, type } = {},
callback
) => () => {
) => {
try {
window.ipcRenderer.send(POST_FILE_CHANNEL, {
userId,
Expand Down Expand Up @@ -36,6 +36,10 @@ export const postFile = async (
}
});
} catch (err) {
console.error(err);
callback({
appInstanceId,
type: POST_FILE_FAILED,
payload: ERROR_POSTING_FILE_MESSAGE,
});
}
};
5 changes: 1 addition & 4 deletions src/components/phase/PhaseApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class PhaseApp extends Component {
folder: PropTypes.string.isRequired,
dispatchGetAppInstance: PropTypes.func.isRequired,
dispatchPostAction: PropTypes.func.isRequired,
dispatchPostFile: PropTypes.func.isRequired,
id: PropTypes.string.isRequired,
phaseId: PropTypes.string.isRequired,
spaceId: PropTypes.string.isRequired,
Expand Down Expand Up @@ -119,7 +118,6 @@ class PhaseApp extends Component {
try {
const {
dispatchGetAppInstance,
dispatchPostFile,
appInstance,
dispatchPostAction,
user,
Expand Down Expand Up @@ -166,7 +164,7 @@ class PhaseApp extends Component {
}
case POST_FILE: {
if (isSpaceSaved) {
return dispatchPostFile(payload, this.postMessage);
return postFile(payload, this.postMessage);
}
break;
}
Expand Down Expand Up @@ -341,7 +339,6 @@ const mapStateToProps = ({ authentication, Space }) => ({
const mapDispatchToProps = {
dispatchGetAppInstance: getAppInstance,
dispatchPostAction: postAction,
dispatchPostFile: postFile,
};

const ConnectedComponent = connect(
Expand Down

0 comments on commit d9145b6

Please sign in to comment.