refactor showing favs and repeats logic
This commit is contained in:
parent
f74a6b4b57
commit
8ed4eb8a7f
6 changed files with 23 additions and 44 deletions
|
@ -41,8 +41,7 @@ const conversation = {
|
|||
props: [
|
||||
'statusoid',
|
||||
'collapsable',
|
||||
'isPage',
|
||||
'timelineName'
|
||||
'isPage'
|
||||
],
|
||||
created () {
|
||||
if (this.isPage) {
|
||||
|
@ -121,8 +120,6 @@ const conversation = {
|
|||
if (this.status) {
|
||||
this.$store.state.api.backendInteractor.fetchConversation({id: this.status.id})
|
||||
.then(({ancestors, descendants}) => {
|
||||
this.$store.dispatch('fetchFavoritedByUsers', { id: this.statusId, retweetedStatusId: this.status.id, timelineName: this.timelineName })
|
||||
this.$store.dispatch('fetchRebloggedByUsers', { id: this.statusId, retweetedStatusId: this.status.id, timelineName: this.timelineName })
|
||||
this.$store.dispatch('addNewStatuses', { statuses: ancestors })
|
||||
this.$store.dispatch('addNewStatuses', { statuses: descendants })
|
||||
})
|
||||
|
@ -142,6 +139,7 @@ const conversation = {
|
|||
},
|
||||
setHighlight (id) {
|
||||
this.highlight = id
|
||||
this.$store.dispatch('fetchFavsAndRepeats', id)
|
||||
},
|
||||
getHighlight () {
|
||||
return this.isExpanded ? this.highlight : null
|
||||
|
|
|
@ -98,6 +98,10 @@ const Status = {
|
|||
return this.statusoid
|
||||
}
|
||||
},
|
||||
statusFromGlobalRepository () {
|
||||
// NOTE: Consider to replace status with statusFromGlobalRepository
|
||||
return this.$store.state.statuses.allStatusesObject[this.status.id]
|
||||
},
|
||||
loggedIn () {
|
||||
return !!this.$store.state.users.currentUser
|
||||
},
|
||||
|
@ -260,7 +264,8 @@ const Status = {
|
|||
return this.status.summary_html + '<br />' + this.status.statusnet_html
|
||||
},
|
||||
combinedFavsAndRepeatsAvatars () {
|
||||
const combinedAvatars = [].concat(this.statusoid.favoritedBy, this.statusoid.rebloggedBy).filter(_ => _)
|
||||
// Use the status from the global status repository since favs and repeats are saved in it
|
||||
const combinedAvatars = [].concat(this.statusFromGlobalRepository.favoritedBy, this.statusFromGlobalRepository.rebloggedBy).filter(_ => _)
|
||||
return uniqBy(combinedAvatars, 'id')
|
||||
}
|
||||
},
|
||||
|
|
|
@ -136,13 +136,13 @@
|
|||
<transition name="fade">
|
||||
<div class="favs-repeated-users" v-if="combinedFavsAndRepeatsAvatars.length > 0 && isFocused">
|
||||
<ul class="stats">
|
||||
<li class="stat-count" v-if="statusoid.rebloggedBy && statusoid.rebloggedBy.length > 0">
|
||||
<li class="stat-count" v-if="statusFromGlobalRepository.rebloggedBy && statusFromGlobalRepository.rebloggedBy.length > 0">
|
||||
<a class="stat-title">{{ $t('settings.notification_visibility_repeats') }}</a>
|
||||
<div class="stat-number">{{ statusoid.rebloggedBy.length }}</div>
|
||||
<div class="stat-number">{{ statusFromGlobalRepository.rebloggedBy.length }}</div>
|
||||
</li>
|
||||
<li class="stat-count" v-if="statusoid.favoritedBy && statusoid.favoritedBy.length > 0">
|
||||
<li class="stat-count" v-if="statusFromGlobalRepository.favoritedBy && statusFromGlobalRepository.favoritedBy.length > 0">
|
||||
<a class="stat-title">{{ $t('user_card.favorites') }}</a>
|
||||
<div class="stat-number">{{ statusoid.favoritedBy.length }}</div>
|
||||
<div class="stat-number">{{ statusFromGlobalRepository.favoritedBy.length }}</div>
|
||||
</li>
|
||||
<li class="avatar-row">
|
||||
<AvatarList :avatars='combinedFavsAndRepeatsAvatars'></AvatarList>
|
||||
|
|
|
@ -16,13 +16,12 @@
|
|||
</div>
|
||||
<div :class="classes.body">
|
||||
<div class="timeline">
|
||||
<conversation
|
||||
<conversation
|
||||
v-for="status in timeline.visibleStatuses"
|
||||
class="status-fadein"
|
||||
:key="status.id"
|
||||
:statusoid="status"
|
||||
:collapsable="true"
|
||||
:timelineName="timelineName"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue