Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use original file name for exports when possible #688

Merged
merged 2 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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