aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/conversation-page/conversation-page.vue6
-rw-r--r--src/components/conversation/conversation.js70
-rw-r--r--src/components/conversation/conversation.vue50
-rw-r--r--src/components/status/status.js1
-rw-r--r--src/components/status/status.vue4
-rw-r--r--src/components/status_or_conversation/status_or_conversation.js22
-rw-r--r--src/components/status_or_conversation/status_or_conversation.vue14
-rw-r--r--src/components/timeline/timeline.js4
-rw-r--r--src/components/timeline/timeline.vue8
-rw-r--r--src/modules/statuses.js14
-rw-r--r--src/modules/users.js26
-rw-r--r--src/services/api/api.service.js106
-rw-r--r--src/services/backend_interactor_service/backend_interactor_service.js8
-rw-r--r--src/services/follow_manipulate/follow_manipulate.js4
14 files changed, 196 insertions, 141 deletions
diff --git a/src/components/conversation-page/conversation-page.vue b/src/components/conversation-page/conversation-page.vue
index b03eea28..9e322cf5 100644
--- a/src/components/conversation-page/conversation-page.vue
+++ b/src/components/conversation-page/conversation-page.vue
@@ -1,5 +1,9 @@
<template>
- <conversation :collapsable="false" :statusoid="statusoid"></conversation>
+ <conversation
+ :collapsable="false"
+ isPage="true"
+ :statusoid="statusoid"
+ ></conversation>
</template>
<script src="./conversation-page.js"></script>
diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js
index e806be8e..69058bf6 100644
--- a/src/components/conversation/conversation.js
+++ b/src/components/conversation/conversation.js
@@ -1,10 +1,12 @@
-import { reduce, filter } from 'lodash'
+import { reduce, filter, findIndex } from 'lodash'
import { set } from 'vue'
import Status from '../status/status.vue'
const sortById = (a, b) => {
- const seqA = Number(a.id)
- const seqB = Number(b.id)
+ const idA = a.type === 'retweet' ? a.retweeted_status.id : a.id
+ const idB = b.type === 'retweet' ? b.retweeted_status.id : b.id
+ const seqA = Number(idA)
+ const seqB = Number(idB)
const isSeqA = !Number.isNaN(seqA)
const isSeqB = !Number.isNaN(seqB)
if (isSeqA && isSeqB) {
@@ -14,12 +16,19 @@ const sortById = (a, b) => {
} else if (!isSeqA && isSeqB) {
return 1
} else {
- return a.id < b.id ? -1 : 1
+ return idA < idB ? -1 : 1
}
}
-const sortAndFilterConversation = (conversation) => {
- conversation = filter(conversation, (status) => status.type !== 'retweet')
+const sortAndFilterConversation = (conversation, statusoid) => {
+ if (statusoid.type === 'retweet') {
+ conversation = filter(
+ conversation,
+ (status) => (status.type === 'retweet' || status.id !== statusoid.retweeted_status.id)
+ )
+ } else {
+ conversation = filter(conversation, (status) => status.type !== 'retweet')
+ }
return conversation.filter(_ => _).sort(sortById)
}
@@ -27,13 +36,20 @@ const conversation = {
data () {
return {
highlight: null,
+ expanded: false,
converationStatusIds: []
}
},
props: [
'statusoid',
- 'collapsable'
+ 'collapsable',
+ 'isPage'
],
+ created () {
+ if (this.isPage) {
+ this.fetchConversation()
+ }
+ },
computed: {
status () {
return this.statusoid
@@ -59,12 +75,22 @@ const conversation = {
return []
}
+ if (!this.isExpanded) {
+ return [this.status]
+ }
+
const statusesObject = this.$store.state.statuses.allStatusesObject
const conversation = this.idsToShow.reduce((acc, id) => {
acc.push(statusesObject[id])
return acc
}, [])
- return sortAndFilterConversation(conversation)
+
+ const statusIndex = findIndex(conversation, { id: this.statusId })
+ if (statusIndex !== -1) {
+ conversation[statusIndex] = this.status
+ }
+
+ return sortAndFilterConversation(conversation, this.status)
},
replies () {
let i = 1
@@ -82,16 +108,21 @@ const conversation = {
i++
return result
}, {})
+ },
+ isExpanded () {
+ return this.expanded || this.isPage
}
},
components: {
Status
},
- created () {
- this.fetchConversation()
- },
watch: {
- '$route': 'fetchConversation'
+ '$route': 'fetchConversation',
+ expanded (value) {
+ if (value) {
+ this.fetchConversation()
+ }
+ }
},
methods: {
fetchConversation () {
@@ -101,9 +132,9 @@ const conversation = {
this.$store.dispatch('addNewStatuses', { statuses: ancestors })
this.$store.dispatch('addNewStatuses', { statuses: descendants })
set(this, 'converationStatusIds', [].concat(
- ancestors.map(_ => _.id),
+ ancestors.map(_ => _.id).filter(_ => _ !== this.statusId),
this.statusId,
- descendants.map(_ => _.id)))
+ descendants.map(_ => _.id).filter(_ => _ !== this.statusId)))
})
.then(() => this.setHighlight(this.statusId))
} else {
@@ -117,10 +148,19 @@ const conversation = {
return this.replies[id] || []
},
focused (id) {
- return id === this.statusId
+ return (this.isExpanded) && id === this.status.id
},
setHighlight (id) {
this.highlight = id
+ },
+ getHighlight () {
+ return this.isExpanded ? this.highlight : null
+ },
+ toggleExpanded () {
+ this.expanded = !this.expanded
+ if (!this.expanded) {
+ this.setHighlight(null)
+ }
}
}
}
diff --git a/src/components/conversation/conversation.vue b/src/components/conversation/conversation.vue
index 5528fef6..c39a3ed9 100644
--- a/src/components/conversation/conversation.vue
+++ b/src/components/conversation/conversation.vue
@@ -1,26 +1,42 @@
<template>
- <div class="timeline panel panel-default">
- <div class="panel-heading conversation-heading">
+ <div class="timeline panel-default" :class="[isExpanded ? 'panel' : 'panel-disabled']">
+ <div v-if="isExpanded" class="panel-heading conversation-heading">
<span class="title"> {{ $t('timeline.conversation') }} </span>
<span v-if="collapsable">
- <a href="#" @click.prevent="$emit('toggleExpanded')">{{ $t('timeline.collapse') }}</a>
+ <a href="#" @click.prevent="toggleExpanded">{{ $t('timeline.collapse') }}</a>
</span>
</div>
- <div class="panel-body">
- <div class="timeline">
- <status
- v-for="status in conversation"
- @goto="setHighlight" :key="status.id"
- :inlineExpanded="collapsable" :statusoid="status"
- :expandable='false' :focused="focused(status.id)"
- :inConversation='true'
- :highlight="highlight"
- :replies="getReplies(status.id)"
- class="status-fadein">
- </status>
- </div>
- </div>
+ <status
+ v-for="status in conversation"
+ @goto="setHighlight"
+ @toggleExpanded="toggleExpanded"
+ :key="status.id"
+ :inlineExpanded="collapsable"
+ :statusoid="status"
+ :expandable='!expanded'
+ :focused="focused(status.id)"
+ :inConversation="isExpanded"
+ :highlight="getHighlight()"
+ :replies="getReplies(status.id)"
+ class="status-fadein panel-body"
+ />
</div>
</template>
<script src="./conversation.js"></script>
+
+<style lang="scss">
+@import '../../_variables.scss';
+
+.timeline {
+ .panel-disabled {
+ .status-el {
+ border-left: none;
+ border-bottom-width: 1px;
+ border-bottom-style: solid;
+ border-color: var(--border, $fallback--border);
+ border-radius: 0;
+ }
+ }
+}
+</style>
diff --git a/src/components/status/status.js b/src/components/status/status.js
index c90da6d4..550fe76f 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -310,7 +310,6 @@ const Status = {
this.replying = !this.replying
},
gotoOriginal (id) {
- // only handled by conversation, not status_or_conversation
if (this.inConversation) {
this.$emit('goto', id)
}
diff --git a/src/components/status/status.vue b/src/components/status/status.vue
index a48b0203..1f415534 100644
--- a/src/components/status/status.vue
+++ b/src/components/status/status.vue
@@ -12,7 +12,7 @@
</div>
</template>
<template v-else>
- <div v-if="retweet && !noHeading" :class="[repeaterClass, { highlighted: repeaterStyle }]" :style="[repeaterStyle]" class="media container retweet-info">
+ <div v-if="retweet && !noHeading && !inConversation" :class="[repeaterClass, { highlighted: repeaterStyle }]" :style="[repeaterStyle]" class="media container retweet-info">
<UserAvatar class="media-left" v-if="retweet" :betterShadow="betterShadow" :src="statusoid.user.profile_image_url_original"/>
<div class="media-body faint">
<span class="user-name">
@@ -24,7 +24,7 @@
</div>
</div>
- <div :class="[userClass, { highlighted: userStyle, 'is-retweet': retweet }]" :style="[ userStyle ]" class="media status">
+ <div :class="[userClass, { highlighted: userStyle, 'is-retweet': retweet && !inConversation }]" :style="[ userStyle ]" class="media status">
<div v-if="!noHeading" class="media-left">
<router-link :to="userProfileLink" @click.stop.prevent.capture.native="toggleUserExpanded">
<UserAvatar :compact="compact" :betterShadow="betterShadow" :src="status.user.profile_image_url_original"/>
diff --git a/src/components/status_or_conversation/status_or_conversation.js b/src/components/status_or_conversation/status_or_conversation.js
deleted file mode 100644
index 441552ca..00000000
--- a/src/components/status_or_conversation/status_or_conversation.js
+++ /dev/null
@@ -1,22 +0,0 @@
-import Status from '../status/status.vue'
-import Conversation from '../conversation/conversation.vue'
-
-const statusOrConversation = {
- props: ['statusoid'],
- data () {
- return {
- expanded: false
- }
- },
- components: {
- Status,
- Conversation
- },
- methods: {
- toggleExpanded () {
- this.expanded = !this.expanded
- }
- }
-}
-
-export default statusOrConversation
diff --git a/src/components/status_or_conversation/status_or_conversation.vue b/src/components/status_or_conversation/status_or_conversation.vue
deleted file mode 100644
index 9647d5eb..00000000
--- a/src/components/status_or_conversation/status_or_conversation.vue
+++ /dev/null
@@ -1,14 +0,0 @@
-<template>
- <div>
- <conversation v-if="expanded" @toggleExpanded="toggleExpanded" :collapsable="true" :statusoid="statusoid"></conversation>
- <status v-if="!expanded" @toggleExpanded="toggleExpanded" :expandable="true" :inConversation="false" :focused="false" :statusoid="statusoid"></status>
- </div>
-</template>
-
-<script src="./status_or_conversation.js"></script>
-
-<style lang="scss">
- .spacer {
- height: 1em
- }
-</style>
diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js
index c45f8947..1da7d5cc 100644
--- a/src/components/timeline/timeline.js
+++ b/src/components/timeline/timeline.js
@@ -1,6 +1,6 @@
import Status from '../status/status.vue'
import timelineFetcher from '../../services/timeline_fetcher/timeline_fetcher.service.js'
-import StatusOrConversation from '../status_or_conversation/status_or_conversation.vue'
+import Conversation from '../conversation/conversation.vue'
import { throttle } from 'lodash'
const Timeline = {
@@ -43,7 +43,7 @@ const Timeline = {
},
components: {
Status,
- StatusOrConversation
+ Conversation
},
created () {
const store = this.$store
diff --git a/src/components/timeline/timeline.vue b/src/components/timeline/timeline.vue
index 8f28d65c..e0a34bd1 100644
--- a/src/components/timeline/timeline.vue
+++ b/src/components/timeline/timeline.vue
@@ -16,7 +16,13 @@
</div>
<div :class="classes.body">
<div class="timeline">
- <status-or-conversation v-for="status in timeline.visibleStatuses" :key="status.id" v-bind:statusoid="status" class="status-fadein"></status-or-conversation>
+ <conversation
+ v-for="status in timeline.visibleStatuses"
+ class="status-fadein"
+ :key="status.id"
+ :statusoid="status"
+ :collapsable="true"
+ />
</div>
</div>
<div :class="classes.footer">
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index a16342e0..944b45c1 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -433,13 +433,6 @@ const statuses = {
// Optimistic favoriting...
commit('setFavorited', { status, value: true })
apiService.favorite({ id: status.id, credentials: rootState.users.currentUser.credentials })
- .then(response => {
- if (response.ok) {
- return response.json()
- } else {
- return {}
- }
- })
.then(status => {
commit('setFavoritedConfirm', { status })
})
@@ -448,13 +441,6 @@ const statuses = {
// Optimistic favoriting...
commit('setFavorited', { status, value: false })
apiService.unfavorite({ id: status.id, credentials: rootState.users.currentUser.credentials })
- .then(response => {
- if (response.ok) {
- return response.json()
- } else {
- return {}
- }
- })
.then(status => {
commit('setFavoritedConfirm', { status })
})
diff --git a/src/modules/users.js b/src/modules/users.js
index 5cfa128e..1a507d31 100644
--- a/src/modules/users.js
+++ b/src/modules/users.js
@@ -1,5 +1,5 @@
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
-import { compact, map, each, merge, find } from 'lodash'
+import { compact, map, each, merge, find, last } from 'lodash'
import { set } from 'vue'
import { registerPushNotifications, unregisterPushNotifications } from '../services/push/push.js'
import oauthApi from '../services/new_api/oauth'
@@ -52,23 +52,23 @@ export const mutations = {
state.loggingIn = false
},
// TODO Clean after ourselves?
- addFriends (state, { id, friends, page }) {
+ addFriends (state, { id, friends }) {
const user = state.usersObject[id]
each(friends, friend => {
if (!find(user.friends, { id: friend.id })) {
user.friends.push(friend)
}
})
- user.friendsPage = page + 1
+ user.lastFriendId = last(friends).id
},
- addFollowers (state, { id, followers, page }) {
+ addFollowers (state, { id, followers }) {
const user = state.usersObject[id]
each(followers, follower => {
if (!find(user.followers, { id: follower.id })) {
user.followers.push(follower)
}
})
- user.followersPage = page + 1
+ user.lastFollowerId = last(followers).id
},
// Because frontend doesn't have a reason to keep these stuff in memory
// outside of viewing someones user profile.
@@ -78,7 +78,7 @@ export const mutations = {
return
}
user.friends = []
- user.friendsPage = 0
+ user.lastFriendId = null
},
clearFollowers (state, userId) {
const user = state.usersObject[userId]
@@ -86,7 +86,7 @@ export const mutations = {
return
}
user.followers = []
- user.followersPage = 0
+ user.lastFollowerId = null
},
addNewUsers (state, users) {
each(users, (user) => mergeOrAdd(state.users, state.usersObject, user))
@@ -219,10 +219,10 @@ const users = {
addFriends ({ rootState, commit }, fetchBy) {
return new Promise((resolve, reject) => {
const user = rootState.users.usersObject[fetchBy]
- const page = user.friendsPage || 1
- rootState.api.backendInteractor.fetchFriends({ id: user.id, page })
+ const maxId = user.lastFriendId
+ rootState.api.backendInteractor.fetchFriends({ id: user.id, maxId })
.then((friends) => {
- commit('addFriends', { id: user.id, friends, page })
+ commit('addFriends', { id: user.id, friends })
resolve(friends)
}).catch(() => {
reject()
@@ -231,10 +231,10 @@ const users = {
},
addFollowers ({ rootState, commit }, fetchBy) {
const user = rootState.users.usersObject[fetchBy]
- const page = user.followersPage || 1
- return rootState.api.backendInteractor.fetchFollowers({ id: user.id, page })
+ const maxId = user.lastFollowerId
+ return rootState.api.backendInteractor.fetchFollowers({ id: user.id, maxId })
.then((followers) => {
- commit('addFollowers', { id: user.id, followers, page })
+ commit('addFollowers', { id: user.id, followers })
return followers
})
},
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index aabbe80f..030c2f5e 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -1,18 +1,7 @@
/* eslint-env browser */
const LOGIN_URL = '/api/account/verify_credentials.json'
const ALL_FOLLOWING_URL = '/api/qvitter/allfollowing'
-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_DELETE_URL = '/api/statuses/destroy'
const MENTIONS_URL = '/api/statuses/mentions.json'
-const DM_TIMELINE_URL = '/api/statuses/dm_timeline.json'
-const FOLLOWERS_URL = '/api/statuses/followers.json'
-const FRIENDS_URL = '/api/statuses/friends.json'
-const FOLLOWING_URL = '/api/friendships/create.json'
-const UNFOLLOWING_URL = '/api/friendships/destroy.json'
const REGISTRATION_URL = '/api/account/register.json'
const AVATAR_UPDATE_URL = '/api/qvitter/update_avatar.json'
const BG_UPDATE_URL = '/api/qvitter/update_background_image.json'
@@ -30,6 +19,16 @@ const DENY_USER_URL = '/api/pleroma/friendships/deny'
const SUGGESTIONS_URL = '/api/v1/suggestions'
const MASTODON_USER_FAVORITES_TIMELINE_URL = '/api/v1/favourites'
+const MASTODON_FAVORITE_URL = id => `/api/v1/statuses/${id}/favourite`
+const MASTODON_UNFAVORITE_URL = id => `/api/v1/statuses/${id}/unfavourite`
+const MASTODON_RETWEET_URL = id => `/api/v1/statuses/${id}/reblog`
+const MASTODON_UNRETWEET_URL = id => `/api/v1/statuses/${id}/unreblog`
+const MASTODON_DELETE_URL = id => `/api/v1/statuses/${id}`
+const MASTODON_FOLLOW_URL = id => `/api/v1/accounts/${id}/follow`
+const MASTODON_UNFOLLOW_URL = id => `/api/v1/accounts/${id}/unfollow`
+const MASTODON_FOLLOWING_URL = id => `/api/v1/accounts/${id}/following`
+const MASTODON_FOLLOWERS_URL = id => `/api/v1/accounts/${id}/followers`
+const MASTODON_DIRECT_MESSAGES_TIMELINE_URL = '/api/v1/timelines/direct'
const MASTODON_PUBLIC_TIMELINE = '/api/v1/timelines/public'
const MASTODON_USER_HOME_TIMELINE_URL = '/api/v1/timelines/home'
const MASTODON_STATUS_URL = id => `/api/v1/statuses/${id}`
@@ -37,6 +36,7 @@ const MASTODON_STATUS_CONTEXT_URL = id => `/api/v1/statuses/${id}/context`
const MASTODON_USER_URL = '/api/v1/accounts'
const MASTODON_USER_RELATIONSHIPS_URL = '/api/v1/accounts/relationships'
const MASTODON_USER_TIMELINE_URL = id => `/api/v1/accounts/${id}/statuses`
+const MASTODON_TAG_TIMELINE_URL = tag => `/api/v1/timelines/tag/${tag}`
const MASTODON_USER_BLOCKS_URL = '/api/v1/blocks/'
const MASTODON_USER_MUTES_URL = '/api/v1/mutes/'
const MASTODON_BLOCK_USER_URL = id => `/api/v1/accounts/${id}/block`
@@ -210,7 +210,7 @@ const externalProfile = ({profileUrl, credentials}) => {
}
const followUser = ({id, credentials}) => {
- let url = `${FOLLOWING_URL}?user_id=${id}`
+ let url = MASTODON_FOLLOW_URL(id)
return fetch(url, {
headers: authHeaders(credentials),
method: 'POST'
@@ -218,7 +218,7 @@ const followUser = ({id, credentials}) => {
}
const unfollowUser = ({id, credentials}) => {
- let url = `${UNFOLLOWING_URL}?user_id=${id}`
+ let url = MASTODON_UNFOLLOW_URL(id)
return fetch(url, {
headers: authHeaders(credentials),
method: 'POST'
@@ -275,28 +275,36 @@ const fetchUserRelationship = ({id, credentials}) => {
})
}
-const fetchFriends = ({id, page, credentials}) => {
- let url = `${FRIENDS_URL}?user_id=${id}`
- if (page) {
- url = url + `&page=${page}`
- }
+const fetchFriends = ({id, maxId, sinceId, limit = 20, credentials}) => {
+ let url = MASTODON_FOLLOWING_URL(id)
+ const args = [
+ maxId && `max_id=${maxId}`,
+ sinceId && `since_id=${sinceId}`,
+ limit && `limit=${limit}`
+ ].filter(_ => _).join('&')
+
+ url = url + (args ? '?' + args : '')
return fetch(url, { headers: authHeaders(credentials) })
.then((data) => data.json())
.then((data) => data.map(parseUser))
}
const exportFriends = ({id, credentials}) => {
- let url = `${FRIENDS_URL}?user_id=${id}&all=true`
+ let url = MASTODON_FOLLOWING_URL(id) + `?all=true`
return fetch(url, { headers: authHeaders(credentials) })
.then((data) => data.json())
.then((data) => data.map(parseUser))
}
-const fetchFollowers = ({id, page, credentials}) => {
- let url = `${FOLLOWERS_URL}?user_id=${id}`
- if (page) {
- url = url + `&page=${page}`
- }
+const fetchFollowers = ({id, maxId, sinceId, limit = 20, credentials}) => {
+ let url = MASTODON_FOLLOWERS_URL(id)
+ const args = [
+ maxId && `max_id=${maxId}`,
+ sinceId && `since_id=${sinceId}`,
+ limit && `limit=${limit}`
+ ].filter(_ => _).join('&')
+
+ url += args ? '?' + args : ''
return fetch(url, { headers: authHeaders(credentials) })
.then((data) => data.json())
.then((data) => data.map(parseUser))
@@ -349,13 +357,13 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false, use
public: MASTODON_PUBLIC_TIMELINE,
friends: MASTODON_USER_HOME_TIMELINE_URL,
mentions: MENTIONS_URL,
- dms: DM_TIMELINE_URL,
+ dms: MASTODON_DIRECT_MESSAGES_TIMELINE_URL,
notifications: QVITTER_USER_NOTIFICATIONS_URL,
'publicAndExternal': MASTODON_PUBLIC_TIMELINE,
user: MASTODON_USER_TIMELINE_URL,
media: MASTODON_USER_TIMELINE_URL,
favorites: MASTODON_USER_FAVORITES_TIMELINE_URL,
- tag: TAG_TIMELINE_URL
+ tag: MASTODON_TAG_TIMELINE_URL
}
const isNotifications = timeline === 'notifications'
const params = []
@@ -373,7 +381,7 @@ const fetchTimeline = ({timeline, credentials, since = false, until = false, use
params.push(['max_id', until])
}
if (tag) {
- url += `/${tag}.json`
+ url = url(tag)
}
if (timeline === 'media') {
params.push(['only_media', 1])
@@ -420,31 +428,63 @@ const verifyCredentials = (user) => {
}
const favorite = ({ id, credentials }) => {
- return fetch(`${FAVORITE_URL}/${id}.json`, {
+ return fetch(MASTODON_FAVORITE_URL(id), {
headers: authHeaders(credentials),
method: 'POST'
})
+ .then(response => {
+ if (response.ok) {
+ return response.json()
+ } else {
+ throw new Error('Error favoriting post')
+ }
+ })
+ .then((data) => parseStatus(data))
}
const unfavorite = ({ id, credentials }) => {
- return fetch(`${UNFAVORITE_URL}/${id}.json`, {
+ return fetch(MASTODON_UNFAVORITE_URL(id), {
headers: authHeaders(credentials),
method: 'POST'
})
+ .then(response => {
+ if (response.ok) {
+ return response.json()
+ } else {
+ throw new Error('Error removing favorite')
+ }
+ })
+ .then((data) => parseStatus(data))
}
const retweet = ({ id, credentials }) => {
- return fetch(`${RETWEET_URL}/${id}.json`, {
+ return fetch(MASTODON_RETWEET_URL(id), {
headers: authHeaders(credentials),
method: 'POST'
})
+ .then(response => {
+ if (response.ok) {
+ return response.json()
+ } else {
+ throw new Error('Error repeating post')
+ }
+ })
+ .then((data) => parseStatus(data))
}
const unretweet = ({ id, credentials }) => {
- return fetch(`${UNRETWEET_URL}/${id}.json`, {
+ return fetch(MASTODON_UNRETWEET_URL(id), {
headers: authHeaders(credentials),
method: 'POST'
})
+ .then(response => {
+ if (response.ok) {
+ return response.json()
+ } else {
+ throw new Error('Error removing repeat')
+ }
+ })
+ .then((data) => parseStatus(data))
}
const postStatus = ({credentials, status, spoilerText, visibility, sensitive, mediaIds = [], inReplyToStatusId, contentType}) => {
@@ -481,9 +521,9 @@ const postStatus = ({credentials, status, spoilerText, visibility, sensitive, me
}
const deleteStatus = ({ id, credentials }) => {
- return fetch(`${STATUS_DELETE_URL}/${id}.json`, {
+ return fetch(MASTODON_DELETE_URL(id), {
headers: authHeaders(credentials),
- method: 'POST'
+ method: 'DELETE'
})
}
diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js
index 0f0bcddc..71e78d2f 100644
--- a/src/services/backend_interactor_service/backend_interactor_service.js
+++ b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -10,16 +10,16 @@ const backendInteractorService = (credentials) => {
return apiService.fetchConversation({id, credentials})
}
- const fetchFriends = ({id, page}) => {
- return apiService.fetchFriends({id, page, credentials})
+ const fetchFriends = ({id, maxId, sinceId, limit}) => {
+ return apiService.fetchFriends({id, maxId, sinceId, limit, credentials})
}
const exportFriends = ({id}) => {
return apiService.exportFriends({id, credentials})
}
- const fetchFollowers = ({id, page}) => {
- return apiService.fetchFollowers({id, page, credentials})
+ const fetchFollowers = ({id, maxId, sinceId, limit}) => {
+ return apiService.fetchFollowers({id, maxId, sinceId, limit, credentials})
}
const fetchAllFollowing = ({username}) => {
diff --git a/src/services/follow_manipulate/follow_manipulate.js b/src/services/follow_manipulate/follow_manipulate.js
index 1e9bd679..51dafe84 100644
--- a/src/services/follow_manipulate/follow_manipulate.js
+++ b/src/services/follow_manipulate/follow_manipulate.js
@@ -19,7 +19,7 @@ const fetchUser = (attempt, user, store) => new Promise((resolve, reject) => {
export const requestFollow = (user, store) => new Promise((resolve, reject) => {
store.state.api.backendInteractor.followUser(user.id)
.then((updated) => {
- store.commit('addNewUsers', [updated])
+ store.commit('updateUserRelationship', [updated])
// For locked users we just mark it that we sent the follow request
if (updated.locked) {
@@ -66,7 +66,7 @@ export const requestFollow = (user, store) => new Promise((resolve, reject) => {
export const requestUnfollow = (user, store) => new Promise((resolve, reject) => {
store.state.api.backendInteractor.unfollowUser(user.id)
.then((updated) => {
- store.commit('addNewUsers', [updated])
+ store.commit('updateUserRelationship', [updated])
resolve({
updated
})