commit: a425cfd04416483fdcd127bdfbd3295d99c1a889
parent: d4f5b3feec1da69b69181b0e8a471bf94e5a5e4c
Author: lambda <pleromagit@rogerbraun.net>
Date: Tue, 19 Jun 2018 09:23:55 +0000
Merge branch 'feature/unrepeats' into 'develop'
Add unretweet support
Closes #103
See merge request pleroma/pleroma-fe!284
Diffstat:
3 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/src/components/retweet_button/retweet_button.js b/src/components/retweet_button/retweet_button.js
@@ -9,6 +9,8 @@ const RetweetButton = {
retweet () {
if (!this.status.repeated) {
this.$store.dispatch('retweet', {id: this.status.id})
+ } else {
+ this.$store.dispatch('unretweet', {id: this.status.id})
}
this.animated = true
setTimeout(() => {
@@ -20,6 +22,7 @@ const RetweetButton = {
classes () {
return {
'retweeted': this.status.repeated,
+ 'retweeted-empty': !this.status.repeated,
'animate-spin': this.animated
}
}
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
@@ -388,6 +388,10 @@ const statuses = {
commit('setRetweeted', { status, value: true })
apiService.retweet({ id: status.id, credentials: rootState.users.currentUser.credentials })
},
+ unretweet ({ rootState, commit }, status) {
+ commit('setRetweeted', { status, value: false })
+ apiService.unretweet({ id: status.id, credentials: rootState.users.currentUser.credentials })
+ },
queueFlush ({ rootState, commit }, { timeline, id }) {
commit('queueFlush', { timeline, id })
}
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
@@ -8,6 +8,7 @@ const TAG_TIMELINE_URL = '/api/statusnet/tags/timeline'
const FAVORITE_URL = '/api/favorites/create'
const UNFAVORITE_URL = '/api/favorites/destroy'
const RETWEET_URL = '/api/statuses/retweet'
+const UNRETWEET_URL = '/api/statuses/unretweet'
const STATUS_UPDATE_URL = '/api/statuses/update.json'
const STATUS_DELETE_URL = '/api/statuses/destroy'
const STATUS_URL = '/api/statuses/show'
@@ -358,6 +359,13 @@ const retweet = ({ id, credentials }) => {
})
}
+const unretweet = ({ id, credentials }) => {
+ return fetch(`${UNRETWEET_URL}/${id}.json`, {
+ headers: authHeaders(credentials),
+ method: 'POST'
+ })
+}
+
const postStatus = ({credentials, status, spoilerText, visibility, mediaIds, inReplyToStatusId}) => {
const idsText = mediaIds.join(',')
const form = new FormData()
@@ -455,6 +463,7 @@ const apiService = {
favorite,
unfavorite,
retweet,
+ unretweet,
postStatus,
deleteStatus,
uploadMedia,