refs #673 Set visibility and sync web instance
This commit is contained in:
parent
885a14c5cb
commit
e0179a6f87
|
@ -34,20 +34,9 @@
|
|||
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import Visibility from '~/src/constants/visibility'
|
||||
|
||||
export default {
|
||||
name: 'Settings',
|
||||
data () {
|
||||
return {
|
||||
visibilities: [
|
||||
Visibility.Public,
|
||||
Visibility.Unlisted,
|
||||
Visibility.Private
|
||||
],
|
||||
tootVisibility: Visibility.Public
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState({
|
||||
primaryColor: state => state.App.theme.primary_color,
|
||||
|
|
|
@ -26,9 +26,21 @@ export default {
|
|||
Visibility.Public,
|
||||
Visibility.Unlisted,
|
||||
Visibility.Private
|
||||
],
|
||||
tootVisibility: Visibility.Public.value
|
||||
]
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
tootVisibility: {
|
||||
get () {
|
||||
return this.$store.state.Settings.General.visibility
|
||||
},
|
||||
set (value) {
|
||||
this.$store.dispatch('Settings/General/setVisibility', value)
|
||||
}
|
||||
}
|
||||
},
|
||||
created () {
|
||||
this.$store.dispatch('Settings/General/fetchVisibility')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
import General from './Settings/General'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
General
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
import Mastodon from 'megalodon'
|
||||
import Visibility from '~/src/constants/visibility'
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
visibility: Visibility.Public.value
|
||||
},
|
||||
mutations: {
|
||||
changeVisibility (state, value) {
|
||||
state.visibility = value
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
fetchVisibility ({ state, 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('changeVisibility', visibility.value)
|
||||
return res.data
|
||||
})
|
||||
},
|
||||
setVisibility ({ state, commit, rootState }, value) {
|
||||
const client = new Mastodon(
|
||||
rootState.TimelineSpace.account.accessToken,
|
||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||
)
|
||||
const visibility = Object.values(Visibility).find((v) => {
|
||||
return v.value === value
|
||||
})
|
||||
return client.patch('/accounts/update_credentials', {
|
||||
source: {
|
||||
privacy: visibility.key
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
commit('changeVisibility', visibility.value)
|
||||
return res.data
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import Login from './Login'
|
|||
import Authorize from './Authorize'
|
||||
import TimelineSpace from './TimelineSpace'
|
||||
import Preferences from './Preferences'
|
||||
import Settings from './Settings'
|
||||
|
||||
Vue.use(Vuex)
|
||||
|
||||
|
@ -22,6 +23,7 @@ export default new Vuex.Store({
|
|||
Login,
|
||||
Authorize,
|
||||
TimelineSpace,
|
||||
Preferences
|
||||
Preferences,
|
||||
Settings
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue