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
|
if (!id) return
|
||||||
this.highlight = id
|
this.highlight = id
|
||||||
this.$store.dispatch('fetchFavsAndRepeats', id)
|
this.$store.dispatch('fetchFavsAndRepeats', id)
|
||||||
|
this.$store.dispatch('fetchEmojiReactions', id)
|
||||||
},
|
},
|
||||||
getHighlight () {
|
getHighlight () {
|
||||||
return this.isExpanded ? this.highlight : null
|
return this.isExpanded ? this.highlight : null
|
||||||
|
|
|
@ -278,6 +278,12 @@ const Status = {
|
||||||
hidePostStats () {
|
hidePostStats () {
|
||||||
return this.mergedConfig.hidePostStats
|
return this.mergedConfig.hidePostStats
|
||||||
},
|
},
|
||||||
|
emojiReactions () {
|
||||||
|
return {
|
||||||
|
'🤔': [{ 'id': 'xyz..' }, { 'id': 'zyx...' }],
|
||||||
|
'🐻': [{ 'id': 'abc...' }]
|
||||||
|
}
|
||||||
|
},
|
||||||
...mapGetters(['mergedConfig'])
|
...mapGetters(['mergedConfig'])
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
|
@ -354,6 +354,17 @@
|
||||||
</div>
|
</div>
|
||||||
</transition>
|
</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
|
<div
|
||||||
v-if="!noHeading && !isPreview"
|
v-if="!noHeading && !isPreview"
|
||||||
class="status-actions media-body"
|
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 {
|
.button-icon.icon-reply {
|
||||||
&:not(.button-icon-disabled):hover,
|
&:not(.button-icon-disabled):hover,
|
||||||
&.button-icon-active {
|
&.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 { set } from 'vue'
|
||||||
import apiService from '../services/api/api.service.js'
|
import apiService from '../services/api/api.service.js'
|
||||||
// import parse from '../services/status_parser/status_parser.js'
|
// import parse from '../services/status_parser/status_parser.js'
|
||||||
|
@ -510,6 +510,11 @@ export const mutations = {
|
||||||
newStatus.fave_num = newStatus.favoritedBy.length
|
newStatus.fave_num = newStatus.favoritedBy.length
|
||||||
newStatus.favorited = !!newStatus.favoritedBy.find(({ id }) => currentUser.id === id)
|
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 }) {
|
updateStatusWithPoll (state, { id, poll }) {
|
||||||
const status = state.allStatusesObject[id]
|
const status = state.allStatusesObject[id]
|
||||||
status.poll = poll
|
status.poll = poll
|
||||||
|
@ -611,6 +616,13 @@ const statuses = {
|
||||||
commit('addRepeats', { id, rebloggedByUsers, currentUser: rootState.users.currentUser })
|
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) {
|
fetchFavs ({ rootState, commit }, id) {
|
||||||
rootState.api.backendInteractor.fetchFavoritedByUsers(id)
|
rootState.api.backendInteractor.fetchFavoritedByUsers(id)
|
||||||
.then(favoritedByUsers => commit('addFavs', { id, favoritedByUsers, currentUser: rootState.users.currentUser }))
|
.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_UNMUTE_CONVERSATION = id => `/api/v1/statuses/${id}/unmute`
|
||||||
const MASTODON_SEARCH_2 = `/api/v2/search`
|
const MASTODON_SEARCH_2 = `/api/v2/search`
|
||||||
const MASTODON_USER_SEARCH_URL = '/api/v1/accounts/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
|
const oldfetch = window.fetch
|
||||||
|
|
||||||
|
@ -864,6 +865,10 @@ const fetchRebloggedByUsers = ({ id }) => {
|
||||||
return promisedRequest({ url: MASTODON_STATUS_REBLOGGEDBY_URL(id) }).then((users) => users.map(parseUser))
|
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 }) => {
|
const reportUser = ({ credentials, userId, statusIds, comment, forward }) => {
|
||||||
return promisedRequest({
|
return promisedRequest({
|
||||||
url: MASTODON_REPORT_USER_URL,
|
url: MASTODON_REPORT_USER_URL,
|
||||||
|
@ -997,6 +1002,7 @@ const apiService = {
|
||||||
fetchPoll,
|
fetchPoll,
|
||||||
fetchFavoritedByUsers,
|
fetchFavoritedByUsers,
|
||||||
fetchRebloggedByUsers,
|
fetchRebloggedByUsers,
|
||||||
|
fetchEmojiReactions,
|
||||||
reportUser,
|
reportUser,
|
||||||
updateNotificationSettings,
|
updateNotificationSettings,
|
||||||
search2,
|
search2,
|
||||||
|
|
|
@ -143,6 +143,7 @@ const backendInteractorService = credentials => {
|
||||||
|
|
||||||
const fetchFavoritedByUsers = (id) => apiService.fetchFavoritedByUsers({ id })
|
const fetchFavoritedByUsers = (id) => apiService.fetchFavoritedByUsers({ id })
|
||||||
const fetchRebloggedByUsers = (id) => apiService.fetchRebloggedByUsers({ id })
|
const fetchRebloggedByUsers = (id) => apiService.fetchRebloggedByUsers({ id })
|
||||||
|
const fetchEmojiReactions = (id) => apiService.fetchEmojiReactions({ id })
|
||||||
const reportUser = (params) => apiService.reportUser({ credentials, ...params })
|
const reportUser = (params) => apiService.reportUser({ credentials, ...params })
|
||||||
|
|
||||||
const favorite = (id) => apiService.favorite({ id, credentials })
|
const favorite = (id) => apiService.favorite({ id, credentials })
|
||||||
|
@ -210,6 +211,7 @@ const backendInteractorService = credentials => {
|
||||||
fetchPoll,
|
fetchPoll,
|
||||||
fetchFavoritedByUsers,
|
fetchFavoritedByUsers,
|
||||||
fetchRebloggedByUsers,
|
fetchRebloggedByUsers,
|
||||||
|
fetchEmojiReactions,
|
||||||
reportUser,
|
reportUser,
|
||||||
favorite,
|
favorite,
|
||||||
unfavorite,
|
unfavorite,
|
||||||
|
|
Loading…
Reference in a new issue