Skip to content

Commit

Permalink
refs #461 Add toot visibility setting in preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
h3poteto committed Aug 1, 2018
1 parent a5eeac7 commit fdd8837
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 37 deletions.
3 changes: 2 additions & 1 deletion src/main/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const Base = {
},
theme: 'white',
fontSize: 14,
displayNameStyle: 0
displayNameStyle: 0,
tootVisibility: 0
},
state: {
collapse: false
Expand Down
101 changes: 66 additions & 35 deletions src/renderer/components/Preferences/General.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@
</tbody>
</table>
</div>
<div class="toot">
<h3>Toot</h3>
<table>
<tbody>
<tr>
<td class="title">Default Visibility:</td>
<td class="status">
<el-select v-model="tootVisibility" placeholder="visibility">
<el-option
v-for="v in visibilities"
:key="v.value"
:label="v.name"
:value="v.value">
</el-option>
</el-select>
</td>
</tr>
</tbody>
</table>
</div>
<div class="sounds">
<h3>Sounds</h3>
<table>
Expand Down Expand Up @@ -82,6 +102,20 @@ export default {
name: 'username',
value: 2
}
],
visibilities: [
{
name: 'public',
value: 0
},
{
name: 'unlisted',
value: 1
},
{
name: 'private',
value: 2
}
]
}
},
Expand All @@ -106,6 +140,14 @@ export default {
this.$store.dispatch('Preferences/General/updateDisplayNameStyle', value)
}
},
tootVisibility: {
get () {
return this.$store.state.Preferences.General.general.tootVisibility
},
set (value) {
this.$store.dispatch('Preferences/General/updateTootVisibility', value)
}
},
sound_fav_rb: {
get () {
return this.$store.state.Preferences.General.general.sound.fav_rb
Expand Down Expand Up @@ -146,52 +188,41 @@ export default {

<style lang="scss" scoped>
#general {
.appearance {
color: var(--theme-secondary-color);
width: 100%;
box-sizing: border-box;
table {
width: 100%;
}
table {
width: 100%;
}
td {
padding: 16px 0;
}
td {
padding: 16px 0;
}
.title {
text-align: right;
width: 50%;
}
.title {
text-align: right;
width: 50%;
}
.status {
width: 50%;
text-align: center;
}
.status {
width: 50%;
text-align: center;
}
.sounds {
.appearance {
color: var(--theme-secondary-color);
width: 100%;
box-sizing: border-box;
}
table {
width: 100%;
}
td {
padding: 16px 0;
}
.title {
text-align: right;
width: 50%;
}
.toot {
color: var(--theme-secondary-color);
width: 100%;
box-sizing: border-box;
}
.status {
width: 50%;
text-align: center;
}
.sounds {
color: var(--theme-secondary-color);
width: 100%;
box-sizing: border-box;
}
}
</style>
20 changes: 19 additions & 1 deletion src/renderer/store/Preferences/General.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ const General = {
},
theme: 'white',
fontSize: 14,
displayNameStyle: 0
displayNameStyle: 0,
tootVisibility: 0
},
loading: false
},
Expand Down Expand Up @@ -94,6 +95,23 @@ const General = {
commit('updateGeneral', conf.general)
})
},
updateTootVisibility ({ dispatch, commit, state }, value) {
const newGeneral = Object.assign({}, state.general, {
tootVisibility: value
})
const config = {
general: newGeneral
}
ipcRenderer.send('save-preferences', config)
ipcRenderer.once('error-save-preferences', (event, err) => {
ipcRenderer.removeAllListeners('response-save-preferences')
})
ipcRenderer.once('response-save-preferences', (event, conf) => {
ipcRenderer.removeAllListeners('error-save-preferences')
dispatch('App/loadPreferences', null, { root: true })
commit('updateGeneral', conf.general)
})
},
updateSound ({ commit, state }, sound) {
commit('changeLoading', true)
const newSound = Object.assign({}, state.general.sound, sound)
Expand Down

0 comments on commit fdd8837

Please sign in to comment.