aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrenden Bice <brenden.next@gmail.com>2019-04-01 22:29:45 -0400
committerBrenden Bice <brenden.next@gmail.com>2019-04-11 23:26:12 -0400
commit2d339cd3b8b3ffc1509c954f68636d8ed4d37253 (patch)
tree0f32e01495eff840132faa00bc10979bf8fc5965 /src
parentfd3811d651f5be0c74f33850df2e95ed18f86a0c (diff)
fetch favorited users
Diffstat (limited to 'src')
-rw-r--r--src/components/conversation/conversation.js12
-rw-r--r--src/components/status/status.js8
-rw-r--r--src/modules/statuses.js11
-rw-r--r--src/services/api/api.service.js27
-rw-r--r--src/services/backend_interactor_service/backend_interactor_service.js4
5 files changed, 60 insertions, 2 deletions
diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js
index 30600f73..b3335f64 100644
--- a/src/components/conversation/conversation.js
+++ b/src/components/conversation/conversation.js
@@ -120,6 +120,8 @@ const conversation = {
if (this.status) {
this.$store.state.api.backendInteractor.fetchConversation({id: this.status.id})
.then(({ancestors, descendants}) => {
+ const ancestorId = ancestors.length ? ancestors[0].id : this.status.id
+ this.fetchFavouritedByUsers(ancestorId)
this.$store.dispatch('addNewStatuses', { statuses: ancestors })
this.$store.dispatch('addNewStatuses', { statuses: descendants })
})
@@ -148,6 +150,16 @@ const conversation = {
if (!this.expanded) {
this.setHighlight(null)
}
+ },
+ fetchFavouritedByUsers (id) {
+ this.$store.state.api.backendInteractor.fetchFavouritedByUsers({id: this.status.id}).then((response) => {
+ const favoritedByUsers = response.map(item => ({
+ src: item.avatar_static,
+ name: item.display_name
+ }))
+ this.$store.dispatch('addFavoritedByUsers', { favoritedByUsers, id })
+ })
+ },
}
}
}
diff --git a/src/components/status/status.js b/src/components/status/status.js
index 0295cd04..e470eaeb 100644
--- a/src/components/status/status.js
+++ b/src/components/status/status.js
@@ -7,6 +7,7 @@ import UserCard from '../user_card/user_card.vue'
import UserAvatar from '../user_avatar/user_avatar.vue'
import Gallery from '../gallery/gallery.vue'
import LinkPreview from '../link-preview/link-preview.vue'
+import AvatarList from '../avatar_list/avatar_list.vue'
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
import fileType from 'src/services/file_type/file_type.service'
import { highlightClass, highlightStyle } from '../../services/user_highlighter/user_highlighter.js'
@@ -257,6 +258,10 @@ const Status = {
return this.status.statusnet_html
}
return this.status.summary_html + '<br />' + this.status.statusnet_html
+ },
+ favouritedByUsers () {
+ return this.statusoid.favoritedBy ? this.statusoid.favoritedBy : []
+ },
}
},
components: {
@@ -268,7 +273,8 @@ const Status = {
UserCard,
UserAvatar,
Gallery,
- LinkPreview
+ LinkPreview,
+ AvatarList
},
methods: {
visibilityIcon (visibility) {
diff --git a/src/modules/statuses.js b/src/modules/statuses.js
index e70c2400..8d2eb424 100644
--- a/src/modules/statuses.js
+++ b/src/modules/statuses.js
@@ -459,6 +459,13 @@ export const mutations = {
},
queueFlush (state, { timeline, id }) {
state.timelines[timeline].flushMarker = id
+ },
+ addFavoritedByUsers (state, { favoritedByUsers, id }) {
+ state.allStatusesObject[id] = {
+ ...state.allStatusesObject[id],
+ favoritedBy: favoritedByUsers
+ }
+ },
}
}
@@ -524,6 +531,10 @@ const statuses = {
id: rootState.statuses.notifications.maxId,
credentials: rootState.users.currentUser.credentials
})
+ },
+ addFavoritedByUsers ({ rootState, commit }, { favoritedByUsers, id }) {
+ commit('addFavoritedByUsers', { favoritedByUsers, id })
+ },
}
},
mutations
diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js
index 2dd52cb5..45eec566 100644
--- a/src/services/api/api.service.js
+++ b/src/services/api/api.service.js
@@ -49,6 +49,7 @@ const MASTODON_MUTE_USER_URL = id => `/api/v1/accounts/${id}/mute`
const MASTODON_UNMUTE_USER_URL = id => `/api/v1/accounts/${id}/unmute`
const MASTODON_POST_STATUS_URL = '/api/v1/statuses'
const MASTODON_MEDIA_UPLOAD_URL = '/api/v1/media'
+const MASTODON_STATUS_FAVOURITEDBY_URL = id => `/api/v1/statuses/${id}/favourited_by`
import { each, map } from 'lodash'
import { parseStatus, parseUser, parseNotification, parseAttachment } from '../entity_normalizer/entity_normalizer.service.js'
@@ -722,6 +723,32 @@ const markNotificationsAsSeen = ({id, credentials}) => {
}).then((data) => data.json())
}
+const fetchFavouritedByUsers = ({id}) => {
+ return fetch(MASTODON_STATUS_FAVOURITEDBY_URL(id), {
+ method: 'GET'
+ })
+ .then(response => {
+ if (response.ok) {
+ return response.json()
+ } else {
+ throw new Error('Error fetching favorited by users')
+ }
+ })
+}
+
+const fetchRebloggedByUsers = ({id}) => {
+ return fetch(MASTODON_STATUS_REBLOGGEDBY_URL(id), {
+ method: 'GET'
+ })
+ .then(response => {
+ if (response.ok) {
+ return response.json()
+ } else {
+ throw new Error('Error reblogged by users')
+ }
+ })
+}
+
const apiService = {
verifyCredentials,
fetchTimeline,
diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js
index 75bba92b..5faec9af 100644
--- a/src/services/backend_interactor_service/backend_interactor_service.js
+++ b/src/services/backend_interactor_service/backend_interactor_service.js
@@ -112,6 +112,7 @@ const backendInteractorService = (credentials) => {
const deleteAccount = ({password}) => apiService.deleteAccount({credentials, password})
const changePassword = ({password, newPassword, newPasswordConfirmation}) => apiService.changePassword({credentials, password, newPassword, newPasswordConfirmation})
+ const fetchFavouritedByUsers = ({id}) => apiService.fetchFavouritedByUsers({id})
const backendInteractorServiceInstance = {
fetchStatus,
fetchConversation,
@@ -152,7 +153,8 @@ const backendInteractorService = (credentials) => {
changePassword,
fetchFollowRequests,
approveUser,
- denyUser
+ denyUser,
+ fetchFavouritedByUsers,
}
return backendInteractorServiceInstance