refs #673 Read visibility settings from instance when new toot

This commit is contained in:
AkiraFukushima 2018-10-29 09:18:27 +09:00
parent e0179a6f87
commit 1690b0b55b
2 changed files with 15 additions and 7 deletions

View File

@ -1,7 +1,6 @@
import { ipcRenderer } from 'electron'
import router from '../router'
import { LightTheme, DarkTheme, SolarizedLightTheme, SolarizedDarkTheme, KimbieDarkTheme } from '../utils/theme'
import Visibility from '~/src/constants/visibility'
import DisplayStyle from '~/src/constants/displayStyle'
import Theme from '~/src/constants/theme'
import TimeFormat from '~/src/constants/timeFormat'
@ -14,7 +13,6 @@ const App = {
theme: LightTheme,
fontSize: 14,
displayNameStyle: DisplayStyle.DisplayNameAndUsername.value,
tootVisibility: Visibility.Public.value,
notify: {
reply: true,
reblog: true,
@ -35,9 +33,6 @@ const App = {
updateDisplayNameStyle (state, value) {
state.displayNameStyle = value
},
updateTootVisibility (state, value) {
state.tootVisibility = value
},
updateNotify (state, notify) {
state.notify = notify
},
@ -73,7 +68,6 @@ const App = {
dispatch('updateTheme', conf.appearance)
commit('updateDisplayNameStyle', conf.appearance.displayNameStyle)
commit('updateFontSize', conf.appearance.fontSize)
commit('updateTootVisibility', conf.general.tootVisibility)
commit('updateNotify', conf.notification.notify)
commit('updateTimeFormat', conf.appearance.timeFormat)
commit('updateLanguage', conf.language.language)

View File

@ -109,7 +109,7 @@ const NewToot = {
if (!state.replyToMessage && state.pinedHashtag) {
commit('updateStatus', state.hashtags.map(t => ` #${t.name}`).join())
}
commit('changeVisibilityValue', rootState.App.tootVisibility)
dispatch('fetchVisibility')
},
closeModal ({ commit }) {
commit('changeModal', false)
@ -155,6 +155,20 @@ const NewToot = {
if (state.pinedHashtag) {
commit('updateHashtags', tags)
}
},
fetchVisibility ({ commit, rootState }) {
const client = new Mastodon(
rootState.TimelineSpace.account.accessToken,
rootState.TimelineSpace.account.baseURL + '/api/v1'
)
return client.get('/accounts/verify_credentials')
.then(res => {
const visibility = Object.values(Visibility).find((v) => {
return v.key === res.data.source.privacy
})
commit('changeVisibilityValue', visibility.value)
return res.data
})
}
}
}