refs #151 Use constants object at display name style
This commit is contained in:
parent
61d65c4081
commit
981805399a
|
@ -0,0 +1,16 @@
|
|||
import i18n from '../config/i18n'
|
||||
|
||||
export default {
|
||||
DisplayNameAndUsername: {
|
||||
name: i18n.t('preferences.general.display_style.display_name_and_username'),
|
||||
value: 0
|
||||
},
|
||||
DisplayName: {
|
||||
name: i18n.t('preferences.general.display_style.display_name'),
|
||||
value: 1
|
||||
},
|
||||
Username: {
|
||||
name: i18n.t('preferences.general.display_style.username'),
|
||||
value: 2
|
||||
}
|
||||
}
|
|
@ -3,18 +3,22 @@ import i18n from '../config/i18n'
|
|||
export default {
|
||||
Public: {
|
||||
name: i18n.t('preferences.general.visibility.public'),
|
||||
value: 0
|
||||
value: 0,
|
||||
key: 'public'
|
||||
},
|
||||
Unlisted: {
|
||||
name: i18n.t('preferences.general.visibility.unlisted'),
|
||||
value: 1
|
||||
value: 1,
|
||||
key: 'unlisted'
|
||||
},
|
||||
Private: {
|
||||
name: i18n.t('preferences.general.visibility.private'),
|
||||
value: 2
|
||||
value: 2,
|
||||
key: 'private'
|
||||
},
|
||||
Direct: {
|
||||
name: i18n.t('preferences.general.visibility.direct'),
|
||||
value: 3
|
||||
value: 3,
|
||||
key: 'direct'
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import storage from 'electron-json-storage'
|
||||
import objectAssignDeep from 'object-assign-deep'
|
||||
import Visibility from '../constants/visibility'
|
||||
import DisplayStyle from '../constants/displayStyle'
|
||||
|
||||
const Base = {
|
||||
general: {
|
||||
|
@ -10,7 +11,7 @@ const Base = {
|
|||
},
|
||||
theme: 'white',
|
||||
fontSize: 14,
|
||||
displayNameStyle: 0,
|
||||
displayNameStyle: DisplayStyle.DisplayNameAndUsername.value,
|
||||
tootVisibility: Visibility.Public.value
|
||||
},
|
||||
state: {
|
||||
|
|
|
@ -85,6 +85,7 @@
|
|||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import Visibility from '../../../constants/visibility'
|
||||
import DisplayStyle from '../../../constants/displayStyle'
|
||||
|
||||
export default {
|
||||
name: 'general',
|
||||
|
@ -94,6 +95,11 @@ export default {
|
|||
Visibility.Public,
|
||||
Visibility.Unlisted,
|
||||
Visibility.Private
|
||||
],
|
||||
nameStyles: [
|
||||
DisplayStyle.DisplayNameAndUsername,
|
||||
DisplayStyle.DisplayName,
|
||||
DisplayStyle.Username
|
||||
]
|
||||
}
|
||||
},
|
||||
|
@ -145,24 +151,6 @@ export default {
|
|||
toot: value
|
||||
})
|
||||
}
|
||||
},
|
||||
nameStyles: {
|
||||
get () {
|
||||
return [
|
||||
{
|
||||
name: this.$t('preferences.general.display_style.display_name_and_username'),
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
name: this.$t('preferences.general.display_style.display_name'),
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
name: this.$t('preferences.general.display_style.username'),
|
||||
value: 2
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
|
|
|
@ -109,6 +109,7 @@ import moment from 'moment'
|
|||
import { shell, clipboard } from 'electron'
|
||||
import { mapState } from 'vuex'
|
||||
import { findAccount, findLink, isTag } from '../../../utils/link'
|
||||
import DisplayStyle from '../../../../../constants/displayStyle'
|
||||
|
||||
export default {
|
||||
name: 'toot',
|
||||
|
@ -143,29 +144,28 @@ export default {
|
|||
},
|
||||
username (account) {
|
||||
switch (this.displayNameStyle) {
|
||||
case 0:
|
||||
case DisplayStyle.DisplayNameAndUsername.value:
|
||||
if (account.display_name !== '') {
|
||||
return account.display_name
|
||||
} else {
|
||||
return account.username
|
||||
}
|
||||
case 1:
|
||||
case DisplayStyle.DisplayName.value:
|
||||
if (account.display_name !== '') {
|
||||
return account.display_name
|
||||
} else {
|
||||
return account.username
|
||||
}
|
||||
case 2:
|
||||
case DisplayStyle.Username.value:
|
||||
return `@${account.username}`
|
||||
}
|
||||
},
|
||||
accountName (account) {
|
||||
switch (this.displayNameStyle) {
|
||||
case 0:
|
||||
case DisplayStyle.DisplayNameAndUsername.value:
|
||||
return `@${account.username}`
|
||||
case 1:
|
||||
return ''
|
||||
case 2:
|
||||
case DisplayStyle.DisplayName.value:
|
||||
case DisplayStyle.Username.value:
|
||||
return ''
|
||||
}
|
||||
},
|
||||
|
|
|
@ -169,7 +169,7 @@ export default {
|
|||
})
|
||||
let form = {
|
||||
status: this.status,
|
||||
visibility: Visibility[visibilityKey].name,
|
||||
visibility: Visibility[visibilityKey].key,
|
||||
sensitive: this.sensitive,
|
||||
spoiler_text: this.spoiler
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
import { ipcRenderer } from 'electron'
|
||||
import router from '../router'
|
||||
import { LightTheme, DarkTheme } from '../utils/theme'
|
||||
import Visibility from '../../constants/visibility'
|
||||
import DisplayStyle from '../../constants/displayStyle'
|
||||
|
||||
const App = {
|
||||
namespaced: true,
|
||||
state: {
|
||||
theme: LightTheme,
|
||||
fontSize: 14,
|
||||
// 0: display name and username
|
||||
// 1: display name
|
||||
// 2: username
|
||||
displayNameStyle: 0
|
||||
displayNameStyle: DisplayStyle.DisplayNameAndUsername.value,
|
||||
tootVisibility: Visibility.Public.value
|
||||
},
|
||||
mutations: {
|
||||
updateTheme (state, themeName) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { ipcRenderer } from 'electron'
|
||||
import Visibility from '../../../constants/visibility'
|
||||
import DisplayStyle from '../../../constants/displayStyle'
|
||||
|
||||
const General = {
|
||||
namespaced: true,
|
||||
|
@ -11,7 +12,7 @@ const General = {
|
|||
},
|
||||
theme: 'white',
|
||||
fontSize: 14,
|
||||
displayNameStyle: 0,
|
||||
displayNameStyle: DisplayStyle.DisplayNameAndUsername.value,
|
||||
tootVisibility: Visibility.Public.value
|
||||
},
|
||||
loading: false
|
||||
|
|
|
@ -45,10 +45,14 @@ const NewToot = {
|
|||
* changeVisibility
|
||||
* Update visibility using Visibility constants
|
||||
* @param state vuex state object
|
||||
* @param visibility Visibility constants object
|
||||
* @param level Visibility level
|
||||
**/
|
||||
changeVisibility (state, visibility) {
|
||||
state.visibility = visibility.value
|
||||
changeVisibility (state, level) {
|
||||
Object.keys(Visibility).map((key, index) => {
|
||||
if (Visibility[key].key === level) {
|
||||
this.visibility = Visibility[key].value
|
||||
}
|
||||
})
|
||||
},
|
||||
/**
|
||||
* changeVisibilityValue
|
||||
|
@ -91,14 +95,11 @@ const NewToot = {
|
|||
.filter((a) => a !== rootState.TimelineSpace.account.username)
|
||||
commit('changeModal', true)
|
||||
commit('updateStatus', `${mentionAccounts.map(m => `@${m}`).join(' ')} `)
|
||||
dispatch('changeVisibility', message.visibility)
|
||||
commit('changeVisibility', message.visibility)
|
||||
},
|
||||
openModal ({ dispatch, commit }) {
|
||||
openModal ({ dispatch, commit, rootState }) {
|
||||
commit('changeModal', true)
|
||||
ipcRenderer.send('get-preferences')
|
||||
ipcRenderer.once('response-get-preferences', (event, conf) => {
|
||||
commit('changeVisibilityValue', conf.general.tootVisibility)
|
||||
})
|
||||
commit('changeVisibilityValue', rootState.tootVisibility)
|
||||
},
|
||||
closeModal ({ commit }) {
|
||||
commit('changeModal', false)
|
||||
|
|
Loading…
Reference in New Issue