refs #461 Use constants for visibility
This commit is contained in:
parent
2dd68338ed
commit
8638bee417
|
@ -0,0 +1,18 @@
|
|||
export default {
|
||||
Public: {
|
||||
name: 'public',
|
||||
value: 0
|
||||
},
|
||||
Unlisted: {
|
||||
name: 'unlisted',
|
||||
value: 1
|
||||
},
|
||||
Private: {
|
||||
name: 'private',
|
||||
value: 2
|
||||
},
|
||||
Direct: {
|
||||
name: 'direct',
|
||||
value: 3
|
||||
}
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
import storage from 'electron-json-storage'
|
||||
import objectAssignDeep from 'object-assign-deep'
|
||||
import Visibility from '../constants/visibility'
|
||||
|
||||
const Base = {
|
||||
general: {
|
||||
|
@ -10,7 +11,7 @@ const Base = {
|
|||
theme: 'white',
|
||||
fontSize: 14,
|
||||
displayNameStyle: 0,
|
||||
tootVisibility: 0
|
||||
tootVisibility: Visibility.Public.value
|
||||
},
|
||||
state: {
|
||||
collapse: false
|
||||
|
|
|
@ -84,6 +84,7 @@
|
|||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import Visibility from '../../../constants/visibility'
|
||||
|
||||
export default {
|
||||
name: 'general',
|
||||
|
@ -104,18 +105,9 @@ export default {
|
|||
}
|
||||
],
|
||||
visibilities: [
|
||||
{
|
||||
name: 'public',
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
name: 'unlisted',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
name: 'private',
|
||||
value: 2
|
||||
}
|
||||
Visibility.Public,
|
||||
Visibility.Unlisted,
|
||||
Visibility.Private
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import Visibility from '../../../../constants/visibility'
|
||||
|
||||
export default {
|
||||
name: 'new-toot',
|
||||
|
@ -79,13 +80,13 @@ export default {
|
|||
sensitive: state => state.TimelineSpace.Modals.NewToot.sensitive,
|
||||
visibilityIcon: (state) => {
|
||||
switch (state.TimelineSpace.Modals.NewToot.visibility) {
|
||||
case 'public':
|
||||
case Visibility.Public.value:
|
||||
return 'globe'
|
||||
case 'unlisted':
|
||||
case Visibility.Unlisted.value:
|
||||
return 'unlock'
|
||||
case 'private':
|
||||
case Visibility.Private.value:
|
||||
return 'lock'
|
||||
case 'direct':
|
||||
case Visibility.Direct.value:
|
||||
return 'envelope'
|
||||
default:
|
||||
return 'globe'
|
||||
|
@ -209,7 +210,7 @@ export default {
|
|||
this.$store.commit('TimelineSpace/Modals/NewToot/removeMedia', media)
|
||||
},
|
||||
changeVisibility (level) {
|
||||
this.$store.commit('TimelineSpace/Modals/NewToot/changeVisibility', level)
|
||||
this.$store.dispatch('TimelineSpace/Modals/NewToot/changeVisibility', level)
|
||||
},
|
||||
changeSensitive () {
|
||||
this.$store.commit('TimelineSpace/Modals/NewToot/changeSensitive', !this.sensitive)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { ipcRenderer } from 'electron'
|
||||
import Visibility from '../../../constants/visibility'
|
||||
|
||||
const General = {
|
||||
namespaced: true,
|
||||
|
@ -11,7 +12,7 @@ const General = {
|
|||
theme: 'white',
|
||||
fontSize: 14,
|
||||
displayNameStyle: 0,
|
||||
tootVisibility: 0
|
||||
tootVisibility: Visibility.Public.value
|
||||
},
|
||||
loading: false
|
||||
},
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import Mastodon from 'megalodon'
|
||||
import { ipcRenderer } from 'electron'
|
||||
import Visibility from '../../../../constants/visibility'
|
||||
|
||||
const NewToot = {
|
||||
namespaced: true,
|
||||
|
@ -9,7 +10,7 @@ const NewToot = {
|
|||
replyToMessage: null,
|
||||
blockSubmit: false,
|
||||
attachedMedias: [],
|
||||
visibility: 'public',
|
||||
visibility: Visibility.Public.value,
|
||||
sensitive: false,
|
||||
spoiler: '',
|
||||
attachedMediaId: 0
|
||||
|
@ -36,8 +37,13 @@ const NewToot = {
|
|||
removeMedia (state, media) {
|
||||
state.attachedMedias = state.attachedMedias.filter(m => m.id !== media.id)
|
||||
},
|
||||
changeVisibility (state, value) {
|
||||
state.visibility = value
|
||||
/**
|
||||
* changeVisibility
|
||||
* @param state vuex state object
|
||||
* @param visibility Visibility constants object
|
||||
**/
|
||||
changeVisibility (state, visibility) {
|
||||
state.visibility = visibility.value
|
||||
},
|
||||
changeSensitive (state, value) {
|
||||
state.sensitive = value
|
||||
|
@ -64,14 +70,14 @@ const NewToot = {
|
|||
return res.data
|
||||
})
|
||||
},
|
||||
openReply ({ commit, rootState }, message) {
|
||||
openReply ({ dispatch, commit, rootState }, message) {
|
||||
commit('setReplyTo', message)
|
||||
const mentionAccounts = [message.account.acct].concat(message.mentions.map(a => a.acct))
|
||||
.filter((a, i, self) => self.indexOf(a) === i)
|
||||
.filter((a) => a !== rootState.TimelineSpace.account.username)
|
||||
commit('changeModal', true)
|
||||
commit('updateStatus', `${mentionAccounts.map(m => `@${m}`).join(' ')} `)
|
||||
commit('changeVisibility', message.visibility)
|
||||
dispatch('changeVisibility', message.visibility)
|
||||
},
|
||||
openModal ({ commit }) {
|
||||
commit('changeModal', true)
|
||||
|
@ -84,7 +90,7 @@ const NewToot = {
|
|||
commit('clearAttachedMedias')
|
||||
commit('changeSensitive', false)
|
||||
commit('updateSpoiler', '')
|
||||
commit('changeVisibility', 'public')
|
||||
commit('changeVisibility', Visibility.Public)
|
||||
},
|
||||
uploadImage ({ state, commit, rootState }, image) {
|
||||
commit('changeBlockSubmit', true)
|
||||
|
@ -115,6 +121,18 @@ const NewToot = {
|
|||
},
|
||||
resetMediaId ({ commit }) {
|
||||
commit('updateMediaId', 0)
|
||||
},
|
||||
/**
|
||||
* changeVisibility
|
||||
* @param commit vuex commit object
|
||||
* @param level visibility level string object
|
||||
**/
|
||||
changeVisibility ({ commit }, level) {
|
||||
Object.keys(Visibility).map((key, index) => {
|
||||
if (Visibility[key].name === level) {
|
||||
commit('changeVisibility', Visibility[key])
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue