Skip to content

Commit

Permalink
Use original file name for exports when possible (#688)
Browse files Browse the repository at this point in the history
  • Loading branch information
karaggeorge authored and sindresorhus committed Jul 8, 2019
1 parent 2cf7b0b commit e70a900
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion main/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const openEditorWindow = async (filePath, {recordedFps, isNewRecording, original

editorWindow.webContents.on('did-finish-load', async () => {
ipc.callRenderer(editorWindow, 'export-options', exportOptions);
await ipc.callRenderer(editorWindow, 'file', {filePath, fps, originalFilePath});
await ipc.callRenderer(editorWindow, 'file', {filePath, fps, originalFilePath, isNewRecording});
editorWindow.show();
});
};
Expand Down
2 changes: 1 addition & 1 deletion main/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Export {
this.isDefault = options.isDefault;

const now = moment();
this.defaultFileName = `Kapture ${now.format('YYYY-MM-DD')} at ${now.format('H.mm.ss')}.${this.format}`;
this.defaultFileName = options.isNewRecording ? `Kapture ${now.format('YYYY-MM-DD')} at ${now.format('H.mm.ss')}.${this.format}` : `${path.parse(this.inputPath).name}.${this.format}`;

this.context = new ShareServiceContext({
format: this.format,
Expand Down
9 changes: 5 additions & 4 deletions renderer/containers/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export default class EditorContainer extends Container {
this.videoContainer = videoContainer;
}

mount = (filePath, fps = 15, originalFilePath, resolve) => {
mount = (filePath, fps = 15, originalFilePath, isNewRecording, resolve) => {
const src = `file://${filePath}`;
this.finishLoading = resolve;

this.setState({src, filePath, originalFilePath, fps, originalFps: fps, wasMuted: false});
this.setState({src, filePath, originalFilePath, fps, originalFps: fps, wasMuted: false, isNewRecording});
this.videoContainer.setSrc(src);
}

Expand Down Expand Up @@ -172,7 +172,7 @@ export default class EditorContainer extends Container {
}

startExport = () => {
const {width, height, fps, filePath, originalFilePath, options, format, plugin: serviceTitle, originalFps} = this.state;
const {width, height, fps, filePath, originalFilePath, options, format, plugin: serviceTitle, originalFps, isNewRecording} = this.state;
const {startTime, endTime, isMuted} = this.videoContainer.state;

const plugin = options.find(option => option.format === format).plugins.find(p => p.title === serviceTitle);
Expand All @@ -193,7 +193,8 @@ export default class EditorContainer extends Container {
isDefault,
serviceTitle,
format,
originalFps
originalFps,
isNewRecording
};

const {ipcRenderer: ipc} = require('electron-better-ipc');
Expand Down
4 changes: 2 additions & 2 deletions renderer/pages/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ export default class EditorPage extends React.Component {
componentDidMount() {
const {ipcRenderer: ipc} = require('electron-better-ipc');

ipc.answerMain('file', async ({filePath, fps, originalFilePath}) => {
ipc.answerMain('file', async ({filePath, fps, originalFilePath, isNewRecording}) => {
await new Promise((resolve, reject) => {
editorContainer.mount(filePath, parseInt(fps, 10), originalFilePath, resolve, reject);
editorContainer.mount(filePath, parseInt(fps, 10), originalFilePath, isNewRecording, resolve, reject);
});
return true;
});
Expand Down

0 comments on commit e70a900

Please sign in to comment.