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

Fix avatar and sound selection (Broken since v1.9.0) #83

Merged
merged 1 commit into from
Nov 14, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use dialog.showOpenDialog by using promise
This was a breaking change in electron v6
  • Loading branch information
dignite committed Nov 14, 2019
commit 7380b5e406f6bbcaf2f53c549ef1c0c3969aa926
53 changes: 28 additions & 25 deletions src/windows/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 56,19 @@ function createMobberEl(mobber) {
}

function selectImage(mobber) {
var image = dialog.showOpenDialog({
title: "Select image",
filters: [{ name: "Images", extensions: ["jpg", "png", "gif"] }],
properties: ["openFile"]
});

if (image) {
mobber.image = image[0];
ipc.send("updateMobber", mobber);
}
return dialog
.showOpenDialog({
title: "Select image",
filters: [{ name: "Images", extensions: ["jpg", "png", "gif"] }],
properties: ["openFile"]
})
.then(selection => {
if (!selection.canceled) {
mobber.image = selection.filePaths[0];
ipc.send("updateMobber", mobber);
}
return;
});
}

function toggleMobberDisabled(mobber) {
Expand Down Expand Up @@ -160,23 163,23 @@ function updateAlertControls() {
}

useCustomSoundCheckbox.addEventListener("change", () => {
let mp3 = null;

if (useCustomSoundCheckbox.checked) {
const selectedMp3 = dialog.showOpenDialog({
title: "Select alert sound",
filters: [{ name: "MP3", extensions: ["mp3"] }],
properties: ["openFile"]
});

if (selectedMp3) {
mp3 = selectedMp3[0];
} else {
useCustomSoundCheckbox.checked = false;
}
return dialog
.showOpenDialog({
title: "Select alert sound",
filters: [{ name: "MP3", extensions: ["mp3"] }],
properties: ["openFile"]
})
.then(selection => {
if (!selection.canceled) {
const mp3 = selection.filePaths[0];
ipc.send("setAlertSound", mp3);
} else {
useCustomSoundCheckbox.checked = false;
}
return;
});
}

ipc.send("setAlertSound", mp3);
});

timerAlwaysOnTopCheckbox.addEventListener("change", () => {
Expand Down