forked from AkkomaGang/akkoma-fe
add fetching for emoji reactions, draft design
This commit is contained in:
parent
1f42283b8d
commit
d007502629
6 changed files with 56 additions and 1 deletions
|
@ -149,6 +149,7 @@ const conversation = {
|
|||
if (!id) return
|
||||
this.highlight = id
|
||||
this.$store.dispatch('fetchFavsAndRepeats', id)
|
||||
this.$store.dispatch('fetchEmojiReactions', id)
|
||||
},
|
||||
getHighlight () {
|
||||
return this.isExpanded ? this.highlight : null
|
||||
|
|
|
@ -278,6 +278,12 @@ const Status = {
|
|||
hidePostStats () {
|
||||
return this.mergedConfig.hidePostStats
|
||||
},
|
||||
emojiReactions () {
|
||||
return {
|
||||
'🤔': [{ 'id': 'xyz..' }, { 'id': 'zyx...' }],
|
||||
'🐻': [{ 'id': 'abc...' }]
|
||||
}
|
||||
},
|
||||
...mapGetters(['mergedConfig'])
|
||||
},
|
||||
components: {
|
||||
|
|
|
@ -354,6 +354,17 @@
|
|||
</div>
|
||||
</transition>
|
||||
|
||||
<div class="emoji-reactions">
|
||||
<button
|
||||
class="emoji-reaction btn btn-default"
|
||||
v-for="(users, emoji) in emojiReactions"
|
||||
:key="emoji"
|
||||
>
|
||||
<span>{{users.length}}</span>
|
||||
<span>{{emoji}}</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="!noHeading && !isPreview"
|
||||
class="status-actions media-body"
|
||||
|
@ -771,6 +782,23 @@ $status-margin: 0.75em;
|
|||
}
|
||||
}
|
||||
|
||||
.emoji-reactions {
|
||||
display: flex;
|
||||
margin-top: 0.75em;
|
||||
}
|
||||
|
||||
.emoji-reaction {
|
||||
padding: 0 0.5em;
|
||||
margin-right: 0.5em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
:first-child {
|
||||
margin-right: 0.25em;
|
||||
}
|
||||
}
|
||||
|
||||
.button-icon.icon-reply {
|
||||
&:not(.button-icon-disabled):hover,
|
||||
&.button-icon-active {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { remove, slice, each, findIndex, find, maxBy, minBy, merge, first, last, isArray, omitBy } from 'lodash'
|
||||
import { remove, slice, each, findIndex, find, maxBy, minBy, merge, first, last, isArray, omitBy, findKey } from 'lodash'
|
||||
import { set } from 'vue'
|
||||
import apiService from '../services/api/api.service.js'
|
||||
// import parse from '../services/status_parser/status_parser.js'
|
||||
|
@ -510,6 +510,11 @@ export const mutations = {
|
|||
newStatus.fave_num = newStatus.favoritedBy.length
|
||||
newStatus.favorited = !!newStatus.favoritedBy.find(({ id }) => currentUser.id === id)
|
||||
},
|
||||
addEmojiReactions (state, { id, emojiReactions, currentUser }) {
|
||||
const status = state.allStatusesObject[id]
|
||||
status.emojiReactions = emojiReactions
|
||||
status.reactedWithEmoji = findKey(emojiReactions, { id: currentUser.id })
|
||||
},
|
||||
updateStatusWithPoll (state, { id, poll }) {
|
||||
const status = state.allStatusesObject[id]
|
||||
status.poll = poll
|
||||
|
@ -611,6 +616,13 @@ const statuses = {
|
|||
commit('addRepeats', { id, rebloggedByUsers, currentUser: rootState.users.currentUser })
|
||||
})
|
||||
},
|
||||
fetchEmojiReactions ({ rootState, commit }, id) {
|
||||
rootState.api.backendInteractor.fetchEmojiReactions(id).then(
|
||||
emojiReactions => {
|
||||
commit('addEmojiReactions', { id, emojiReactions, currentUser: rootState.users.currentUser })
|
||||
}
|
||||
)
|
||||
},
|
||||
fetchFavs ({ rootState, commit }, id) {
|
||||
rootState.api.backendInteractor.fetchFavoritedByUsers(id)
|
||||
.then(favoritedByUsers => commit('addFavs', { id, favoritedByUsers, currentUser: rootState.users.currentUser }))
|
||||
|
|
|
@ -71,6 +71,7 @@ const MASTODON_MUTE_CONVERSATION = id => `/api/v1/statuses/${id}/mute`
|
|||
const MASTODON_UNMUTE_CONVERSATION = id => `/api/v1/statuses/${id}/unmute`
|
||||
const MASTODON_SEARCH_2 = `/api/v2/search`
|
||||
const MASTODON_USER_SEARCH_URL = '/api/v1/accounts/search'
|
||||
const PLEROMA_EMOJI_REACTIONS_URL = id => `/api/v1/pleroma/statuses/${id}/emoji_reactions_by`
|
||||
|
||||
const oldfetch = window.fetch
|
||||
|
||||
|
@ -864,6 +865,10 @@ const fetchRebloggedByUsers = ({ id }) => {
|
|||
return promisedRequest({ url: MASTODON_STATUS_REBLOGGEDBY_URL(id) }).then((users) => users.map(parseUser))
|
||||
}
|
||||
|
||||
const fetchEmojiReactions = ({ id }) => {
|
||||
return promisedRequest({ url: PLEROMA_EMOJI_REACTIONS_URL(id) })
|
||||
}
|
||||
|
||||
const reportUser = ({ credentials, userId, statusIds, comment, forward }) => {
|
||||
return promisedRequest({
|
||||
url: MASTODON_REPORT_USER_URL,
|
||||
|
@ -997,6 +1002,7 @@ const apiService = {
|
|||
fetchPoll,
|
||||
fetchFavoritedByUsers,
|
||||
fetchRebloggedByUsers,
|
||||
fetchEmojiReactions,
|
||||
reportUser,
|
||||
updateNotificationSettings,
|
||||
search2,
|
||||
|
|
|
@ -143,6 +143,7 @@ const backendInteractorService = credentials => {
|
|||
|
||||
const fetchFavoritedByUsers = (id) => apiService.fetchFavoritedByUsers({ id })
|
||||
const fetchRebloggedByUsers = (id) => apiService.fetchRebloggedByUsers({ id })
|
||||
const fetchEmojiReactions = (id) => apiService.fetchEmojiReactions({ id })
|
||||
const reportUser = (params) => apiService.reportUser({ credentials, ...params })
|
||||
|
||||
const favorite = (id) => apiService.favorite({ id, credentials })
|
||||
|
@ -210,6 +211,7 @@ const backendInteractorService = credentials => {
|
|||
fetchPoll,
|
||||
fetchFavoritedByUsers,
|
||||
fetchRebloggedByUsers,
|
||||
fetchEmojiReactions,
|
||||
reportUser,
|
||||
favorite,
|
||||
unfavorite,
|
||||
|
|
Loading…
Reference in a new issue