Browse Source

Merge pull request #147 from fizmat/fix-dialog-api

Fix electron dialog api for backup/restore
pull/3202/head
TheGoddessInari 5 years ago committed by GitHub
parent
commit
cc80d29619
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      app/ux/FileBackup.js

16
app/ux/FileBackup.js

@ -23,13 +23,15 @@ Ext.define('Hamsket.ux.FileBackup', {
const json_string = JSON.stringify(services, null, 4);
me.remote.dialog.showSaveDialog({
defaultPath: me.myDefaultPath
}, function(filename, bookmark) {
if (!filename) return;
me.fs.writeFile(filename, json_string, function(err) {
}).then((result) => {
if (!result.filePath) return;
me.fs.writeFile(result.filePath, json_string, function(err) {
if (err) {
console.log(err);
}
});
}).catch((err) => {
console.log(err);
});
if (Ext.isFunction(callback)) callback.bind(me)();
},
@ -38,9 +40,9 @@ Ext.define('Hamsket.ux.FileBackup', {
me.remote.dialog.showOpenDialog({
defaultPath: me.myDefaultPath,
properties: ['openFile']
}, function(filePaths, bookmarks) {
if (filePaths && filePaths.length === 1) {
const filePath = filePaths[0];
}).then((result) => {
if (result.filePaths && result.filePaths.length === 1) {
const filePath = result.filePaths[0];
me.fs.readFile(filePath, function (err, data) {
if (err) {
console.log(err);
@ -59,6 +61,8 @@ Ext.define('Hamsket.ux.FileBackup', {
}
});
}
}).catch((err) => {
console.log(err);
});
}
});

Loading…
Cancel
Save