Skip to content

Commit

Permalink
Fixed issue with electron dialog error on cancel.
Browse files Browse the repository at this point in the history
Closes #1261
  • Loading branch information
imolorhe committed Jun 8, 2020
1 parent e543b6a commit a948855
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions packages/altair-electron/src/utils/backup.js
Expand Up @@ -19,7 +19,11 @@ const importBackupData = (instance) => {
filters: [
{ name: 'Altair GraphQL Backup Files', extensions: [ 'agbkp' ] },
],
}, ([ filePath ]) => {
}).then(({ canceled, filePaths: [ filePath ] }) => {
if (canceled) {
return;
}

if (filePath) {
const fileContent = fs.readFileSync(filePath, 'utf8');
try {
Expand All @@ -46,14 +50,20 @@ const exportBackupData = (instance) => {
filters: [
{ name: 'Altair GraphQL Backup Files', extensions: [ 'agbkp' ] },
],
}, (saveFilePath) => {
// Save to file
const localstoreContent = fs.readFileSync(getPersistentStore().path, 'utf8');
const backupData = {
version: 1,
localstore: JSON.parse(localstoreContent),
};
fs.writeFileSync(saveFilePath, JSON.stringify(backupData));
}).then(({ canceled, filePath }) => {
if (canceled) {
return;
}

if (filePath) {
// Save to file
const localstoreContent = fs.readFileSync(getPersistentStore().path, 'utf8');
const backupData = {
version: 1,
localstore: JSON.parse(localstoreContent),
};
fs.writeFileSync(filePath, JSON.stringify(backupData));
}
});
};

Expand Down

0 comments on commit a948855

Please sign in to comment.