Add sensitive settings and sync to each instance

This commit is contained in:
AkiraFukushima 2018-10-29 22:55:40 +09:00
parent 951083540a
commit 00d6bd7347
8 changed files with 60 additions and 17 deletions

View File

@ -77,13 +77,15 @@
"title": "Settings",
"toot": {
"title": "Toot",
"description": "Customize default visibility of toot.",
"visibility": {
"title": "Standard-Sichtbarkeit",
"description": "Customize default visibility of toot.",
"public": "Öffenlich",
"unlisted": "Nicht gelistet",
"private": "Privat",
"direct": "Direkt"
},
"sensitive": {
"description": "Mark medias as sensitive by default"
}
}
}

View File

@ -78,13 +78,15 @@
"title": "General",
"toot": {
"title": "Toot",
"description": "Customize default visibility of toot.",
"visibility": {
"title": "Default visibility",
"description": "Customize default visibility of toot.",
"public": "Public",
"unlisted": "Unlisted",
"private": "Private",
"direct": "Direct"
},
"sensitive": {
"description": "Mark medias as sensitive by default"
}
}
}

View File

@ -78,13 +78,15 @@
"title": "Général",
"toot": {
"title": "Pouet",
"description": "Customize default visibility of toot.",
"visibility": {
"title": "Visibilité par défaut",
"description": "Customize default visibility of toot.",
"public": "Public",
"unlisted": "Public sans être affiché sur le fil public",
"private": "Abonné⋅e⋅s uniquement",
"direct": "Message direct"
},
"sensitive": {
"description": "Mark medias as sensitive by default"
}
}
}

View File

@ -77,13 +77,15 @@
"general": {
"toot": {
"title": "トゥート",
"description": "トゥートの公開設定を変更できます",
"visibility": {
"title": "公開設定",
"description": "トゥートの公開設定を変更する",
"public": "公開",
"unlisted": "未収載",
"private": "フォロワー限定",
"direct": "ダイレクト"
},
"sensitive": {
"description": "メディアを常に閲覧注意として投稿する"
}
}
}

View File

@ -78,13 +78,15 @@
"title": "일반",
"toot": {
"title": "툿",
"description": "툿의 기본 공개범위를 변경합니다.",
"visibility": {
"title": "기본 공개 범위 설정",
"description": "툿의 기본 공개범위를 변경합니다.",
"public": "공개",
"unlisted": "미등록",
"private": "비공개",
"direct": "다이렉트"
},
"sensitive": {
"description": "Mark medias as sensitive by default"
}
}
}

View File

@ -78,13 +78,15 @@
"title": "Ogólne",
"toot": {
"title": "Wpisy",
"description": "Customize default visibility of toot.",
"visibility": {
"title": "Domyślna widoczność",
"description": "Customize default visibility of toot.",
"public": "Publiczne",
"unlisted": "Niewidoczne",
"private": "Prywatne",
"direct": "Bezpośrednie"
},
"sensitive": {
"description": "Mark medias as sensitive by default"
}
}
}

View File

@ -2,7 +2,7 @@
<div id="general">
<div class="toot section">
<h3>{{ $t('settings.general.toot.title') }}</h3>
<p class="description">{{ $t('settings.general.toot.description') }}</p>
<p class="description">{{ $t('settings.general.toot.visibility.description') }}</p>
<el-select v-model="tootVisibility" placeholder="visibility">
<el-option
v-for="v in visibilities"
@ -11,6 +11,9 @@
:value="v.value">
</el-option>
</el-select>
<p class="description">{{ $t('settings.general.toot.sensitive.description') }}</p>
<el-switch v-model="tootSensitive">
</el-switch>
</div>
</div>
</template>
@ -37,10 +40,18 @@ export default {
set (value) {
this.$store.dispatch('Settings/General/setVisibility', value)
}
},
tootSensitive: {
get () {
return this.$store.state.Settings.General.sensitive
},
set (value) {
this.$store.dispatch('Settings/General/setSensitive', value)
}
}
},
created () {
this.$store.dispatch('Settings/General/fetchVisibility')
this.$store.dispatch('Settings/General/fetchSettings')
}
}
</script>
@ -48,7 +59,7 @@ export default {
<style lang="scss" scoped>
#general {
.description {
margin: 24px 0 20px;
margin: 32px 0 20px;
}
.section {

View File

@ -4,15 +4,19 @@ import Visibility from '~/src/constants/visibility'
export default {
namespaced: true,
state: {
visibility: Visibility.Public.value
visibility: Visibility.Public.value,
sensitive: false
},
mutations: {
changeVisibility (state, value) {
state.visibility = value
},
changeSensitive (state, value) {
state.sensitive = value
}
},
actions: {
fetchVisibility ({ state, commit, rootState }) {
fetchSettings ({ state, commit, rootState }) {
const client = new Mastodon(
rootState.TimelineSpace.account.accessToken,
rootState.TimelineSpace.account.baseURL + '/api/v1'
@ -23,6 +27,7 @@ export default {
return v.key === res.data.source.privacy
})
commit('changeVisibility', visibility.value)
commit('changeSensitive', res.data.source.sensitive)
return res.data
})
},
@ -43,6 +48,21 @@ export default {
commit('changeVisibility', visibility.value)
return res.data
})
},
setSensitive ({ state, commit, rootState }, value) {
const client = new Mastodon(
rootState.TimelineSpace.account.accessToken,
rootState.TimelineSpace.account.baseURL + '/api/v1'
)
return client.patch('/accounts/update_credentials', {
source: {
sensitive: value
}
})
.then(res => {
commit('changeSensitive', value)
return res.data
})
}
}
}