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