Skip to content

Commit

Permalink
refs #461 Set default visibility from preferences in new toot modal
Browse files Browse the repository at this point in the history
  • Loading branch information
h3poteto committed Aug 1, 2018
1 parent 8638bee commit af43064
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/renderer/components/TimelineSpace/Modals/NewToot.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,12 @@ export default {
type: 'error'
})
}
const visibilityKey = Object.keys(Visibility).find((key) => {
return Visibility[key].value === this.visibility
})
let form = {
status: this.status,
visibility: this.visibility,
visibility: Visibility[visibilityKey].name,
sensitive: this.sensitive,
spoiler_text: this.spoiler
}
Expand Down
16 changes: 15 additions & 1 deletion src/renderer/store/TimelineSpace/Modals/NewToot.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,22 @@ const NewToot = {
},
/**
* changeVisibility
* Update visibility using Visibility constants
* @param state vuex state object
* @param visibility Visibility constants object
**/
changeVisibility (state, visibility) {
state.visibility = visibility.value
},
/**
* changeVisibilityValue
* Update visibility using direct value
* @param state vuex state object
* @param value visibility value
**/
changeVisibilityValue (state, value) {
state.visibility = value
},
changeSensitive (state, value) {
state.sensitive = value
},
Expand Down Expand Up @@ -79,8 +89,12 @@ const NewToot = {
commit('updateStatus', `${mentionAccounts.map(m => `@${m}`).join(' ')} `)
dispatch('changeVisibility', message.visibility)
},
openModal ({ commit }) {
openModal ({ dispatch, commit }) {
commit('changeModal', true)
ipcRenderer.send('get-preferences')
ipcRenderer.once('response-get-preferences', (event, conf) => {
commit('changeVisibilityValue', conf.general.tootVisibility)
})
},
closeModal ({ commit }) {
commit('changeModal', false)
Expand Down

0 comments on commit af43064

Please sign in to comment.