Merge pull request #589 from h3poteto/fix/general
Fix bug for save preference in general
This commit is contained in:
commit
1fe4fa7be9
|
@ -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)
|
||||||
|
|
|
@ -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)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue