refs #193 Check preferences before sound

This commit is contained in:
AkiraFukushima 2018-04-07 23:18:20 +09:00
parent 5a42fa767b
commit 5b79bc1181
3 changed files with 31 additions and 17 deletions

View File

@ -45,6 +45,10 @@ const preferencesDBPath = process.env.NODE_ENV === 'production'
? userData + './db/preferences.json'
: 'preferences.json'
const soundBasePath = process.env.NODE_ENV === 'development'
? path.join(__dirname, '../../build/sounds/')
: path.join(process.resourcesPath, 'build/sounds/')
async function listAccounts () {
try {
const account = new Account(accountDB)
@ -449,22 +453,32 @@ ipcMain.on('stop-public-streaming', (event, _) => {
})
// sounds
ipcMain.on('operation-sound01', (event, _) => {
const sound = process.env.NODE_ENV === 'development'
? path.join(__dirname, '../../build/sounds/operation_sound01.wav')
: path.join(process.resourcesPath, 'build/sounds/operation_sound01.wav')
simplayer(sound, (err) => {
if (err) log.error(err)
})
ipcMain.on('fav-rt-action-sound', (event, _) => {
const preferences = new Preferences(preferencesDBPath)
preferences.load()
.then((conf) => {
if (conf.general.sound.fav_rb) {
const sound = path.join(soundBasePath, 'operation_sound01.wav')
simplayer(sound, (err) => {
if (err) log.error(err)
})
}
})
.catch(err => log.error(err))
})
ipcMain.on('operation-sound02', (event, _) => {
const sound = process.env.NODE_ENV === 'development'
? path.join(__dirname, '../../build/sounds/operation_sound02.wav')
: path.join(process.resourcesPath, 'build/sounds/operation_sound02.wav')
simplayer(sound, (err) => {
if (err) log.error(err)
})
ipcMain.on('toot-action-sound', (event, _) => {
const preferences = new Preferences(preferencesDBPath)
preferences.load()
.then((conf) => {
if (conf.general.sound.toot) {
const sound = path.join(soundBasePath, 'operation_sound02.wav')
simplayer(sound, (err) => {
if (err) log.error(err)
})
}
})
.catch(err => log.error(err))
})
// preferences

View File

@ -20,7 +20,7 @@ const Toot = {
// Reblog target status is in the data.reblog.
// So I send data.reblog as status for update local timeline.
commit('TimelineSpace/updateToot', data.reblog, { root: true })
ipcRenderer.send('operation-sound01')
ipcRenderer.send('fav-rt-action-sound')
resolve(data.reblog)
})
})
@ -51,7 +51,7 @@ const Toot = {
client.post(`/statuses/${message.id}/favourite`, {}, (err, data, res) => {
if (err) return reject(err)
commit('TimelineSpace/updateToot', data, { root: true })
ipcRenderer.send('operation-sound01')
ipcRenderer.send('fav-rt-action-sound')
resolve(data)
})
})

View File

@ -48,7 +48,7 @@ const NewToot = {
)
client.post('/statuses', form, (err, data, res) => {
if (err) return reject(err)
ipcRenderer.send('operation-sound02')
ipcRenderer.send('toot-action-sound')
resolve(res)
})
})