Skip to content

Commit

Permalink
Remove use of Saver object from renderer
Browse files Browse the repository at this point in the history
Don't need it!
  • Loading branch information
muffinista committed May 14, 2020
1 parent 07ca764 commit b3e9d6e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 24 deletions.
12 changes: 4 additions & 8 deletions src/renderer/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ import SaverOptionInput from "@/components/SaverOptionInput";
import SaverOptions from "@/components/SaverOptions";
import Noty from "noty";
import Saver from "@/../lib/saver";
const { ipcRenderer } = require("electron");
export default {
Expand Down Expand Up @@ -317,14 +315,12 @@ export default {
closeWindow() {
ipcRenderer.send("close-window", "editor");
},
saveData() {
async saveData() {
this.disabled = true;
this.saver.options = this.options;
// @todo use ipc to update saver?
const s = new Saver(this.saver);
s.write(this.saver, this.src);
await ipcRenderer.invoke("save-screensaver", this.saver, this.src);
ipcRenderer.send("savers-updated", this.src);
new Noty({
Expand All @@ -339,8 +335,8 @@ export default {
this.disabled = false;
},
saveDataAndClose() {
this.saveData();
async saveDataAndClose() {
await this.saveData();
this.closeWindow();
},
openFolder() {
Expand Down
26 changes: 10 additions & 16 deletions src/renderer/Prefs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ import SaverOptions from "@/components/SaverOptions";
import SaverSummary from "@/components/SaverSummary";
import Noty from "noty";
import Saver from "@/../lib/saver";
const { ipcRenderer } = require("electron");
const log = require("electron-log");
Expand Down Expand Up @@ -217,29 +215,25 @@ export default {
ipcRenderer.send("open-window", "settings");
},
async getData() {
const tmpList = await ipcRenderer.invoke("list-savers");
// @todo shouldn't need Saver object here
this.savers = tmpList.map((data) => {
return new Saver(data);
});
var tmp = {};
this.savers = await ipcRenderer.invoke("list-savers");
if ( this.savers.length <= 0 ) {
return;
}
// ensure default settings in the config for all savers
for(var i = 0, l = this.savers.length; i < l; i++ ) {
var s = this.savers[i];
// tmp[s.key] = this.prefs.getOptions(s.key);
// if ( tmp[s.key] === undefined ) {
// tmp.options[s.key] = {};
// }
this.savers = this.savers.map((s) => {
if ( s.settings === undefined ) {
s.settings = {};
}
return s;
});
// generate a hash of saver options by key
this.savers.forEach((s) => {
tmp[s.key] = s.settings;
}
});
this.options = Object.assign({}, this.options, tmp);
Expand Down

0 comments on commit b3e9d6e

Please sign in to comment.