diff --git a/src/main/index.js b/src/main/index.js index 6fb77434..920b2668 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -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) => { const preferences = new Preferences(preferencesDBPath) preferences.update(data) diff --git a/src/renderer/store/Preferences/General.js b/src/renderer/store/Preferences/General.js index e332d95f..e077b556 100644 --- a/src/renderer/store/Preferences/General.js +++ b/src/renderer/store/Preferences/General.js @@ -52,13 +52,13 @@ const General = { const config = { general: newGeneral } - ipcRenderer.send('save-preferences', config) - ipcRenderer.once('error-save-preferences', (event, err) => { - ipcRenderer.removeAllListeners('response-save-preferences') + ipcRenderer.send('update-preferences', config) + ipcRenderer.once('error-update-preferences', (event, err) => { + ipcRenderer.removeAllListeners('response-update-preferences') commit('changeLoading', false) }) - ipcRenderer.once('response-save-preferences', (event, conf) => { - ipcRenderer.removeAllListeners('error-save-preferences') + ipcRenderer.once('response-update-preferences', (event, conf) => { + ipcRenderer.removeAllListeners('error-update-preferences') commit('updateGeneral', conf.general) dispatch('App/loadPreferences', null, { root: true }) commit('changeLoading', false) @@ -71,12 +71,12 @@ const General = { const config = { general: newGeneral } - ipcRenderer.send('save-preferences', config) - ipcRenderer.once('error-save-preferences', (event, err) => { - ipcRenderer.removeAllListeners('response-save-preferences') + ipcRenderer.send('update-preferences', config) + ipcRenderer.once('error-update-preferences', (event, err) => { + ipcRenderer.removeAllListeners('response-update-preferences') }) - ipcRenderer.once('response-save-preferences', (event, conf) => { - ipcRenderer.removeAllListeners('error-save-preferences') + ipcRenderer.once('response-update-preferences', (event, conf) => { + ipcRenderer.removeAllListeners('error-update-preferences') commit('updateGeneral', conf.general) dispatch('App/loadPreferences', null, { root: true }) }) @@ -88,12 +88,12 @@ const General = { const config = { general: newGeneral } - ipcRenderer.send('save-preferences', config) - ipcRenderer.once('error-save-preferences', (event, err) => { - ipcRenderer.removeAllListeners('response-save-preferences') + ipcRenderer.send('update-preferences', config) + ipcRenderer.once('error-update-preferences', (event, err) => { + ipcRenderer.removeAllListeners('response-update-preferences') }) - ipcRenderer.once('response-save-preferences', (event, conf) => { - ipcRenderer.removeAllListeners('error-save-preferences') + ipcRenderer.once('response-update-preferences', (event, conf) => { + ipcRenderer.removeAllListeners('error-update-preferences') dispatch('App/loadPreferences', null, { root: true }) commit('updateGeneral', conf.general) }) @@ -105,12 +105,12 @@ const General = { const config = { general: newGeneral } - ipcRenderer.send('save-preferences', config) - ipcRenderer.once('error-save-preferences', (event, err) => { - ipcRenderer.removeAllListeners('response-save-preferences') + ipcRenderer.send('update-preferences', config) + ipcRenderer.once('error-update-preferences', (event, err) => { + ipcRenderer.removeAllListeners('response-update-preferences') }) - ipcRenderer.once('response-save-preferences', (event, conf) => { - ipcRenderer.removeAllListeners('error-save-preferences') + ipcRenderer.once('response-update-preferences', (event, conf) => { + ipcRenderer.removeAllListeners('error-update-preferences') dispatch('App/loadPreferences', null, { root: true }) commit('updateGeneral', conf.general) }) @@ -124,13 +124,13 @@ const General = { const config = { general: newGeneral } - ipcRenderer.send('save-preferences', config) - ipcRenderer.once('error-save-preferences', (event, err) => { - ipcRenderer.removeAllListeners('response-save-preferences') + ipcRenderer.send('update-preferences', config) + ipcRenderer.once('error-update-preferences', (event, err) => { + ipcRenderer.removeAllListeners('response-update-preferences') commit('changeLoading', false) }) - ipcRenderer.once('response-save-preferences', (event, conf) => { - ipcRenderer.removeAllListeners('error-save-preferences') + ipcRenderer.once('response-update-preferences', (event, conf) => { + ipcRenderer.removeAllListeners('error-update-preferences') commit('updateGeneral', conf.general) commit('changeLoading', false) })