Browse Source

Locally scope requires in FileBackup.

This shouldn't be logically different, but when packing everything
it escapes the file scope, so limit it in scope explicitly.
pull/3202/head
TheGoddessInari 6 years ago
parent
commit
dea40d0e22
No known key found for this signature in database
GPG Key ID: 1209B1B7632D69A
  1. 31
      app/ux/FileBackup.js

31
app/ux/FileBackup.js

@ -1,14 +1,13 @@
const remote = require('electron').remote;
const dialog = remote.dialog;
const app = remote.app;
const fs = require('fs');
const path = require('path');
const userPath = app.getPath('userData');
const defaultFileName = 'rambox-backup.json';
const myDefaultPath = userPath + path.sep + defaultFileName;
Ext.define('Rambox.ux.FileBackup', {
singleton: true,
initComponent: () => {
this.remote = require('electron').remote;
this.path = this.remote.require('path');
this.fs = this.remote.require('fs');
this.userPath = this.remote.app.getPath('userData');
this.defaultFileName = 'rambox-backup.json';
this.myDefaultPath = this.userPath + this.path.sep + this.defaultFileName;
},
backupConfiguration: function (callback) {
var me = this;
let services = [];
@ -20,11 +19,11 @@ Ext.define('Rambox.ux.FileBackup', {
});
const json_string = JSON.stringify(services, null, 4);
dialog.showSaveDialog({
defaultPath: myDefaultPath
me.remote.dialog.showSaveDialog({
defaultPath: me.myDefaultPath
}, function(filename, bookmark) {
if (!filename) return;
fs.writeFile(filename, json_string, function(err) {
me.fs.writeFile(filename, json_string, function(err) {
if (err) {
console.log(err);
}
@ -34,13 +33,13 @@ Ext.define('Rambox.ux.FileBackup', {
},
restoreConfiguration: function () {
var me = this;
dialog.showOpenDialog({
defaultPath: myDefaultPath,
me.remote.dialog.showOpenDialog({
defaultPath: me.myDefaultPath,
properties: ['openFile']
}, function(filePaths, bookmarks) {
if (filePaths && filePaths.length === 1) {
const filePath = filePaths[0];
fs.readFile(filePath, function (err, data) {
me.fs.readFile(filePath, function (err, data) {
if (err) {
console.log(err);
}
@ -52,7 +51,7 @@ Ext.define('Rambox.ux.FileBackup', {
service.save();
Ext.getStore('Services').add(service);
});
remote.getCurrentWindow().reload();
me.remote.getCurrentWindow().reload();
});
}

Loading…
Cancel
Save