Skip to content

Commit

Permalink
✨ Improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
adlerluiz committed Aug 25, 2020
1 parent 8acb786 commit 12cca64
Showing 1 changed file with 31 additions and 24 deletions.
55 changes: 31 additions & 24 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1872,32 +1872,39 @@ function registerGlobalShortcut(value, fn) {
}

function updateTrayAudioOutputs(data) {
let audioOutputs = JSON.parse(data)
let selectedAudio = settingsProvider.get('settings-app-audio-output')
let result = [
{
label: __.trans(
'LABEL_SETTINGS_TAB_GENERAL_AUDIO_NO_DEVICES_FOUND'
),
enabled: false,
},
]

if (audioOutputs.length) {
audioOutputs.forEach((value, index) => {
audioOutputs[index] = {
label: value.label,
type: 'radio',
checked: value.label == selectedAudio ? true : false,
click: function () {
ipcMain.emit('change-audio-output', value.label)
},
}
try {
let audioOutputs = JSON.parse(data)
let selectedAudio = settingsProvider.get('settings-app-audio-output')
let result = [
{
label: __.trans(
'LABEL_SETTINGS_TAB_GENERAL_AUDIO_NO_DEVICES_FOUND'
),
enabled: false,
},
]

if (audioOutputs.length) {
audioOutputs.forEach((value, index) => {
audioOutputs[index] = {
label: value.label,
type: 'radio',
checked: value.label == selectedAudio ? true : false,
click: function () {
ipcMain.emit('change-audio-output', value.label)
},
}
})
result = audioOutputs
}

tray.updateTray({ type: 'audioOutputs', data: result })
} catch (error) {
writeLog({
type: 'warn',
data: 'Failed to updateTrayAudioOutputs ' + error,
})
result = audioOutputs
}

tray.updateTray({ type: 'audioOutputs', data: result })
}

function updateStatusBar() {
Expand Down

0 comments on commit 12cca64

Please sign in to comment.