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