Fix bug for save preference in general

This commit is contained in:
AkiraFukushima 2018-08-30 23:21:46 +09:00
parent c5f1df1476
commit 6adbc11480
2 changed files with 25 additions and 38 deletions

View File

@ -578,19 +578,6 @@ ipcMain.on('get-preferences', (event, _) => {
}) })
}) })
// TODO: do not use save-preferences
// Because it update all preferences as default
ipcMain.on('save-preferences', (event, data) => {
const preferences = new Preferences(preferencesDBPath)
preferences.save(data)
.then((conf) => {
event.sender.send('response-save-preferences', conf)
})
.catch((err) => {
event.sender.send('error-save-preferences', err)
})
})
ipcMain.on('update-preferences', (event, data) => { ipcMain.on('update-preferences', (event, data) => {
const preferences = new Preferences(preferencesDBPath) const preferences = new Preferences(preferencesDBPath)
preferences.update(data) preferences.update(data)

View File

@ -52,13 +52,13 @@ const General = {
const config = { const config = {
general: newGeneral general: newGeneral
} }
ipcRenderer.send('save-preferences', config) ipcRenderer.send('update-preferences', config)
ipcRenderer.once('error-save-preferences', (event, err) => { ipcRenderer.once('error-update-preferences', (event, err) => {
ipcRenderer.removeAllListeners('response-save-preferences') ipcRenderer.removeAllListeners('response-update-preferences')
commit('changeLoading', false) commit('changeLoading', false)
}) })
ipcRenderer.once('response-save-preferences', (event, conf) => { ipcRenderer.once('response-update-preferences', (event, conf) => {
ipcRenderer.removeAllListeners('error-save-preferences') ipcRenderer.removeAllListeners('error-update-preferences')
commit('updateGeneral', conf.general) commit('updateGeneral', conf.general)
dispatch('App/loadPreferences', null, { root: true }) dispatch('App/loadPreferences', null, { root: true })
commit('changeLoading', false) commit('changeLoading', false)
@ -71,12 +71,12 @@ const General = {
const config = { const config = {
general: newGeneral general: newGeneral
} }
ipcRenderer.send('save-preferences', config) ipcRenderer.send('update-preferences', config)
ipcRenderer.once('error-save-preferences', (event, err) => { ipcRenderer.once('error-update-preferences', (event, err) => {
ipcRenderer.removeAllListeners('response-save-preferences') ipcRenderer.removeAllListeners('response-update-preferences')
}) })
ipcRenderer.once('response-save-preferences', (event, conf) => { ipcRenderer.once('response-update-preferences', (event, conf) => {
ipcRenderer.removeAllListeners('error-save-preferences') ipcRenderer.removeAllListeners('error-update-preferences')
commit('updateGeneral', conf.general) commit('updateGeneral', conf.general)
dispatch('App/loadPreferences', null, { root: true }) dispatch('App/loadPreferences', null, { root: true })
}) })
@ -88,12 +88,12 @@ const General = {
const config = { const config = {
general: newGeneral general: newGeneral
} }
ipcRenderer.send('save-preferences', config) ipcRenderer.send('update-preferences', config)
ipcRenderer.once('error-save-preferences', (event, err) => { ipcRenderer.once('error-update-preferences', (event, err) => {
ipcRenderer.removeAllListeners('response-save-preferences') ipcRenderer.removeAllListeners('response-update-preferences')
}) })
ipcRenderer.once('response-save-preferences', (event, conf) => { ipcRenderer.once('response-update-preferences', (event, conf) => {
ipcRenderer.removeAllListeners('error-save-preferences') ipcRenderer.removeAllListeners('error-update-preferences')
dispatch('App/loadPreferences', null, { root: true }) dispatch('App/loadPreferences', null, { root: true })
commit('updateGeneral', conf.general) commit('updateGeneral', conf.general)
}) })
@ -105,12 +105,12 @@ const General = {
const config = { const config = {
general: newGeneral general: newGeneral
} }
ipcRenderer.send('save-preferences', config) ipcRenderer.send('update-preferences', config)
ipcRenderer.once('error-save-preferences', (event, err) => { ipcRenderer.once('error-update-preferences', (event, err) => {
ipcRenderer.removeAllListeners('response-save-preferences') ipcRenderer.removeAllListeners('response-update-preferences')
}) })
ipcRenderer.once('response-save-preferences', (event, conf) => { ipcRenderer.once('response-update-preferences', (event, conf) => {
ipcRenderer.removeAllListeners('error-save-preferences') ipcRenderer.removeAllListeners('error-update-preferences')
dispatch('App/loadPreferences', null, { root: true }) dispatch('App/loadPreferences', null, { root: true })
commit('updateGeneral', conf.general) commit('updateGeneral', conf.general)
}) })
@ -124,13 +124,13 @@ const General = {
const config = { const config = {
general: newGeneral general: newGeneral
} }
ipcRenderer.send('save-preferences', config) ipcRenderer.send('update-preferences', config)
ipcRenderer.once('error-save-preferences', (event, err) => { ipcRenderer.once('error-update-preferences', (event, err) => {
ipcRenderer.removeAllListeners('response-save-preferences') ipcRenderer.removeAllListeners('response-update-preferences')
commit('changeLoading', false) commit('changeLoading', false)
}) })
ipcRenderer.once('response-save-preferences', (event, conf) => { ipcRenderer.once('response-update-preferences', (event, conf) => {
ipcRenderer.removeAllListeners('error-save-preferences') ipcRenderer.removeAllListeners('error-update-preferences')
commit('updateGeneral', conf.general) commit('updateGeneral', conf.general)
commit('changeLoading', false) commit('changeLoading', false)
}) })