mirror of
https://akkoma.dev/AkkomaGang/akkoma-fe
synced 2025-06-16 03:09:13 +08:00
Add support selectable visibility of repeat
Co-authored-by: Oneric <oneric@oneric.stub>
This commit is contained in:
parent
4734e9668d
commit
d617a9596a
5 changed files with 31 additions and 9 deletions
|
@ -1,4 +1,6 @@
|
||||||
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
|
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
|
||||||
|
import ScopeSelector from '../scope_selector/scope_selector.vue'
|
||||||
|
import scopeUtils from 'src/lib/scope_utils.js'
|
||||||
import { library } from '@fortawesome/fontawesome-svg-core'
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
import { faRetweet } from '@fortawesome/free-solid-svg-icons'
|
import { faRetweet } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
||||||
|
@ -7,12 +9,14 @@ library.add(faRetweet)
|
||||||
const RetweetButton = {
|
const RetweetButton = {
|
||||||
props: ['status', 'loggedIn', 'visibility'],
|
props: ['status', 'loggedIn', 'visibility'],
|
||||||
components: {
|
components: {
|
||||||
ConfirmModal
|
ConfirmModal,
|
||||||
|
ScopeSelector
|
||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
animated: false,
|
animated: false,
|
||||||
showingConfirmDialog: false
|
showingConfirmDialog: false,
|
||||||
|
retweetVisibility: this.$store.state.users.currentUser.default_scope
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -25,7 +29,7 @@ const RetweetButton = {
|
||||||
},
|
},
|
||||||
doRetweet () {
|
doRetweet () {
|
||||||
if (!this.status.repeated) {
|
if (!this.status.repeated) {
|
||||||
this.$store.dispatch('retweet', { id: this.status.id })
|
this.$store.dispatch('retweet', { id: this.status.id, visibility: this.retweetVisibility })
|
||||||
} else {
|
} else {
|
||||||
this.$store.dispatch('unretweet', { id: this.status.id })
|
this.$store.dispatch('unretweet', { id: this.status.id })
|
||||||
}
|
}
|
||||||
|
@ -40,6 +44,9 @@ const RetweetButton = {
|
||||||
},
|
},
|
||||||
hideConfirmDialog () {
|
hideConfirmDialog () {
|
||||||
this.showingConfirmDialog = false
|
this.showingConfirmDialog = false
|
||||||
|
},
|
||||||
|
changeVis (visibility) {
|
||||||
|
this.retweetVisibility = visibility
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -54,6 +61,15 @@ const RetweetButton = {
|
||||||
},
|
},
|
||||||
remoteInteractionLink () {
|
remoteInteractionLink () {
|
||||||
return this.$store.getters.remoteInteractionLink({ statusId: this.status.id })
|
return this.$store.getters.remoteInteractionLink({ statusId: this.status.id })
|
||||||
|
},
|
||||||
|
userDefaultScope () {
|
||||||
|
return this.$store.state.users.currentUser.default_scope
|
||||||
|
},
|
||||||
|
statusScope () {
|
||||||
|
return this.status.visibility
|
||||||
|
},
|
||||||
|
initialScope () {
|
||||||
|
return scopeUtils.negotiate(this.userDefaultScope, this.status.visibility)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,12 @@
|
||||||
@cancelled="hideConfirmDialog"
|
@cancelled="hideConfirmDialog"
|
||||||
>
|
>
|
||||||
{{ $t('status.repeat_confirm') }}
|
{{ $t('status.repeat_confirm') }}
|
||||||
|
<scope-selector
|
||||||
|
:user-default="userDefaultScope"
|
||||||
|
:original-scope="statusScope"
|
||||||
|
:initial-scope="initialScope"
|
||||||
|
:on-scope-change="changeVis"
|
||||||
|
/>
|
||||||
</confirm-modal>
|
</confirm-modal>
|
||||||
</teleport>
|
</teleport>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -26,7 +26,7 @@ const ScopeSelector = {
|
||||||
],
|
],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
currentScope: this.initialscope;
|
currentScope: this.initialScope
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -663,10 +663,10 @@ const statuses = {
|
||||||
return rootState.api.backendInteractor.unmuteConversation({ id: statusId })
|
return rootState.api.backendInteractor.unmuteConversation({ id: statusId })
|
||||||
.then((status) => commit('setMutedStatus', status))
|
.then((status) => commit('setMutedStatus', status))
|
||||||
},
|
},
|
||||||
retweet ({ rootState, commit }, status) {
|
retweet ({ rootState, commit }, {id, visibility}) {
|
||||||
// Optimistic retweeting...
|
// Optimistic retweeting...
|
||||||
commit('setRetweeted', { status, value: true })
|
commit('setRetweeted', { status: {id: id}, value: true })
|
||||||
rootState.api.backendInteractor.retweet({ id: status.id })
|
rootState.api.backendInteractor.retweet({ id: id, visibility: visibility })
|
||||||
.then(status => commit('setRetweetedConfirm', { status: status.retweeted_status, user: rootState.users.currentUser }))
|
.then(status => commit('setRetweetedConfirm', { status: status.retweeted_status, user: rootState.users.currentUser }))
|
||||||
},
|
},
|
||||||
unretweet ({ rootState, commit }, status) {
|
unretweet ({ rootState, commit }, status) {
|
||||||
|
|
|
@ -822,8 +822,8 @@ const unfavorite = ({ id, credentials }) => {
|
||||||
.then((data) => parseStatus(data))
|
.then((data) => parseStatus(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
const retweet = ({ id, credentials }) => {
|
const retweet = ({ id, visibility, credentials }) => {
|
||||||
return promisedRequest({ url: MASTODON_RETWEET_URL(id), method: 'POST', credentials })
|
return promisedRequest({ url: MASTODON_RETWEET_URL(id), method: 'POST', payload: { visibility }, credentials })
|
||||||
.then((data) => parseStatus(data))
|
.then((data) => parseStatus(data))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue