refs #581 Switch and save notification setting
This commit is contained in:
parent
618c154182
commit
5b43b606d5
|
@ -578,6 +578,8 @@ 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)
|
||||
|
@ -589,6 +591,17 @@ ipcMain.on('save-preferences', (event, data) => {
|
|||
})
|
||||
})
|
||||
|
||||
ipcMain.on('update-preferences', (event, data) => {
|
||||
const preferences = new Preferences(preferencesDBPath)
|
||||
preferences.update(data)
|
||||
.then((conf) => {
|
||||
event.sender.send('response-update-preferences', conf)
|
||||
})
|
||||
.catch((err) => {
|
||||
event.sender.send('error-update-preferences', err)
|
||||
})
|
||||
})
|
||||
|
||||
ipcMain.on('change-collapse', (event, value) => {
|
||||
const preferences = new Preferences(preferencesDBPath)
|
||||
preferences.update(
|
||||
|
|
|
@ -21,6 +21,14 @@ const Base = {
|
|||
},
|
||||
language: {
|
||||
language: Language.en.key
|
||||
},
|
||||
notification: {
|
||||
notify: {
|
||||
reply: true,
|
||||
reblog: true,
|
||||
favourite: true,
|
||||
follow: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
<td class="title">{{ $t('preferences.notification.notify.reply') }}</td>
|
||||
<td class="status">
|
||||
<el-switch
|
||||
v-model="notifyReply"
|
||||
active-color="#13ce66">
|
||||
</el-switch>
|
||||
</td>
|
||||
|
@ -17,6 +18,7 @@
|
|||
<td class="title">{{ $t('preferences.notification.notify.reblog') }}</td>
|
||||
<td class="status">
|
||||
<el-switch
|
||||
v-model="notifyReblog"
|
||||
active-color="#13ce66">
|
||||
</el-switch>
|
||||
</td>
|
||||
|
@ -25,6 +27,7 @@
|
|||
<td class="title">{{ $t('preferences.notification.notify.favourite') }}</td>
|
||||
<td class="status">
|
||||
<el-switch
|
||||
v-model="notifyFavourite"
|
||||
active-color="#13ce66">
|
||||
</el-switch>
|
||||
</td>
|
||||
|
@ -33,6 +36,7 @@
|
|||
<td class="title">{{ $t('preferences.notification.notify.follow') }}</td>
|
||||
<td class="status">
|
||||
<el-switch
|
||||
v-model="notifyFollow"
|
||||
active-color="#13ce66">
|
||||
</el-switch>
|
||||
</td>
|
||||
|
@ -45,7 +49,49 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
name: 'notification'
|
||||
name: 'notification',
|
||||
computed: {
|
||||
notifyReply: {
|
||||
get () {
|
||||
return this.$store.state.Preferences.Notification.notification.notify.reply
|
||||
},
|
||||
set (value) {
|
||||
this.$store.dispatch('Preferences/Notification/updateNotify', {
|
||||
reply: value
|
||||
})
|
||||
}
|
||||
},
|
||||
notifyReblog: {
|
||||
get () {
|
||||
return this.$store.state.Preferences.Notification.notification.notify.reblog
|
||||
},
|
||||
set (value) {
|
||||
this.$store.dispatch('Preferences/Notification/updateNotify', {
|
||||
reblog: value
|
||||
})
|
||||
}
|
||||
},
|
||||
notifyFavourite: {
|
||||
get () {
|
||||
return this.$store.state.Preferences.Notification.notification.notify.favourite
|
||||
},
|
||||
set (value) {
|
||||
this.$store.dispatch('Preferences/Notification/updateNotify', {
|
||||
favourite: value
|
||||
})
|
||||
}
|
||||
},
|
||||
notifyFollow: {
|
||||
get () {
|
||||
return this.$store.state.Preferences.Notification.notification.notify.follow
|
||||
},
|
||||
set (value) {
|
||||
this.$store.dispatch('Preferences/Notification/updateNotify', {
|
||||
follow: value
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
import { ipcRenderer } from 'electron'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
notification: {
|
||||
notify: {
|
||||
reply: true,
|
||||
reblog: true,
|
||||
favourite: true,
|
||||
follow: true
|
||||
}
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
updateNotification (state, notification) {
|
||||
state.notification = notification
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
updateNotify ({ commit, state }, notify) {
|
||||
const newNotify = Object.assign({}, state.notification.notify, notify)
|
||||
const newNotification = Object.assign({}, state.notification, {
|
||||
notify: newNotify
|
||||
})
|
||||
const config = {
|
||||
notification: newNotification
|
||||
}
|
||||
ipcRenderer.send('update-preferences', config)
|
||||
ipcRenderer.once('response-update-preferences', (event, conf) => {
|
||||
commit('updateNotification', conf.notification)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue