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

Save the last used directory #687

Merged
merged 4 commits into from Jul 8, 2019
Merged
Changes from 2 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
5 changes: 4 additions & 1 deletion main/export-list.js
Expand Up @@ -2,6 +2,7 @@
'use strict';
const {dialog, BrowserWindow} = require('electron');
const fs = require('fs');
const {dirname} = require('path');
const pify = require('pify');
const {ipcMain: ipc} = require('electron-better-ipc');
const base64Img = require('base64-img');
Expand All @@ -22,6 +23,7 @@ const Export = require('./export');

const ffmpegPath = util.fixPathForAsarUnpack(ffmpeg.path);
const showSaveDialog = pify(dialog.showSaveDialog, {errorFirst: false});
let lastSavedDir = null;
karaggeorge marked this conversation as resolved.
Show resolved Hide resolved

const filterMap = new Map([
['mp4', [{name: 'Movies', extensions: ['mp4']}]],
Expand Down Expand Up @@ -136,12 +138,13 @@ class ExportList {

const filePath = await showSaveDialog(exportsWindow, {
title: newExport.defaultFileName,
defaultPath: `${kapturesDir}/${newExport.defaultFileName}`,
defaultPath: `${lastSavedDir || kapturesDir}/${newExport.defaultFileName}`,
filters
});

if (filePath) {
newExport.context.targetFilePath = filePath;
lastSavedDir = dirname(filePath);
} else {
if (!wasExportsWindowOpen) {
exportsWindow.close();
Expand Down