Add support selectable visibility of repeat #345

Open
jadiunr wants to merge 1 commit from jadiunr/akkoma-fe:add-support-selectable-visibility-of-repeat into develop
4 changed files with 20 additions and 6 deletions

View file

@ -1,4 +1,5 @@
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
import ScopeSelector from '../scope_selector/scope_selector.vue'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faRetweet } from '@fortawesome/free-solid-svg-icons'
@ -7,12 +8,14 @@ library.add(faRetweet)
const RetweetButton = {
props: ['status', 'loggedIn', 'visibility'],
components: {
ConfirmModal
ConfirmModal,
ScopeSelector
},
data () {
return {
animated: false,
showingConfirmDialog: false
showingConfirmDialog: false,
retweetVisibility: this.$store.state.users.currentUser.default_scope
}
},
methods: {
@ -25,7 +28,7 @@ const RetweetButton = {
},
doRetweet () {
if (!this.status.repeated) {
this.$store.dispatch('retweet', { id: this.status.id })
this.$store.dispatch('retweet', { id: this.status.id, visibility: this.retweetVisibility })
} else {
this.$store.dispatch('unretweet', { id: this.status.id })
}
@ -40,6 +43,9 @@ const RetweetButton = {
},
hideConfirmDialog () {
this.showingConfirmDialog = false
},
changeVis (visibility) {
this.retweetVisibility = visibility
}
},
computed: {
@ -54,6 +60,9 @@ const RetweetButton = {
},
remoteInteractionLink () {
return this.$store.getters.remoteInteractionLink({ statusId: this.status.id })
},
userDefaultScope () {
return this.$store.state.users.currentUser.default_scope
}
}
}

View file

@ -49,6 +49,11 @@
@cancelled="hideConfirmDialog"
>
{{ $t('status.repeat_confirm') }}
<scope-selector
:user-default="userDefaultScope"
:initial-scope="userDefaultScope"
:on-scope-change="changeVis"
/>
</confirm-modal>
</teleport>
</div>

View file

@ -666,7 +666,7 @@ const statuses = {
retweet ({ rootState, commit }, status) {
// Optimistic retweeting...
commit('setRetweeted', { status, value: true })
rootState.api.backendInteractor.retweet({ id: status.id })
rootState.api.backendInteractor.retweet({ id: status.id, visibility: status.visibility })
.then(status => commit('setRetweetedConfirm', { status: status.retweeted_status, user: rootState.users.currentUser }))
},
unretweet ({ rootState, commit }, status) {

View file

@ -822,8 +822,8 @@ const unfavorite = ({ id, credentials }) => {
.then((data) => parseStatus(data))
}
const retweet = ({ id, credentials }) => {
return promisedRequest({ url: MASTODON_RETWEET_URL(id), method: 'POST', credentials })
const retweet = ({ id, visibility, credentials }) => {
return promisedRequest({ url: MASTODON_RETWEET_URL(id), method: 'POST', payload: { visibility }, credentials })
.then((data) => parseStatus(data))
}