Merge branch 'favorites' into 'develop'
Add Favorites TL to user profile, add some initial support for MastoAPI Closes #265 and #262 See merge request pleroma/pleroma-fe!462
This commit is contained in:
commit
3a3cf1d48a
19 changed files with 2361 additions and 252 deletions
|
@ -1,5 +1,5 @@
|
|||
import Conversation from '../conversation/conversation.vue'
|
||||
import { find, toInteger } from 'lodash'
|
||||
import { find } from 'lodash'
|
||||
|
||||
const conversationPage = {
|
||||
components: {
|
||||
|
@ -7,7 +7,7 @@ const conversationPage = {
|
|||
},
|
||||
computed: {
|
||||
statusoid () {
|
||||
const id = toInteger(this.$route.params.id)
|
||||
const id = this.$route.params.id
|
||||
const statuses = this.$store.state.statuses.allStatuses
|
||||
const status = find(statuses, {id})
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { reduce, filter, sortBy } from 'lodash'
|
||||
import { statusType } from '../../modules/statuses.js'
|
||||
import Status from '../status/status.vue'
|
||||
|
||||
const sortAndFilterConversation = (conversation) => {
|
||||
conversation = filter(conversation, (status) => statusType(status) !== 'retweet')
|
||||
conversation = filter(conversation, (status) => status.type !== 'retweet')
|
||||
return sortBy(conversation, 'id')
|
||||
}
|
||||
|
||||
|
@ -18,10 +17,12 @@ const conversation = {
|
|||
'collapsable'
|
||||
],
|
||||
computed: {
|
||||
status () { return this.statusoid },
|
||||
status () {
|
||||
return this.statusoid
|
||||
},
|
||||
conversation () {
|
||||
if (!this.status) {
|
||||
return false
|
||||
return []
|
||||
}
|
||||
|
||||
const conversationId = this.status.statusnet_conversation_id
|
||||
|
@ -32,7 +33,9 @@ const conversation = {
|
|||
replies () {
|
||||
let i = 1
|
||||
return reduce(this.conversation, (result, {id, in_reply_to_status_id}) => {
|
||||
const irid = Number(in_reply_to_status_id)
|
||||
/* eslint-disable camelcase */
|
||||
const irid = in_reply_to_status_id
|
||||
/* eslint-enable camelcase */
|
||||
if (irid) {
|
||||
result[irid] = result[irid] || []
|
||||
result[irid].push({
|
||||
|
@ -69,7 +72,6 @@ const conversation = {
|
|||
}
|
||||
},
|
||||
getReplies (id) {
|
||||
id = Number(id)
|
||||
return this.replies[id] || []
|
||||
},
|
||||
focused (id) {
|
||||
|
@ -80,7 +82,7 @@ const conversation = {
|
|||
}
|
||||
},
|
||||
setHighlight (id) {
|
||||
this.highlight = Number(id)
|
||||
this.highlight = id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,7 +129,7 @@ const Status = {
|
|||
if (this.status.user.id === this.$store.state.users.currentUser.id) {
|
||||
return false
|
||||
}
|
||||
if (this.status.activity_type === 'repeat') {
|
||||
if (this.status.type === 'retweet') {
|
||||
return false
|
||||
}
|
||||
var checkFollowing = this.$store.state.config.replyVisibility === 'following'
|
||||
|
@ -258,7 +258,7 @@ const Status = {
|
|||
},
|
||||
replyEnter (id, event) {
|
||||
this.showPreview = true
|
||||
const targetId = Number(id)
|
||||
const targetId = id
|
||||
const statuses = this.$store.state.statuses.allStatuses
|
||||
|
||||
if (!this.preview) {
|
||||
|
@ -283,7 +283,6 @@ const Status = {
|
|||
},
|
||||
watch: {
|
||||
'highlight': function (id) {
|
||||
id = Number(id)
|
||||
if (this.status.id === id) {
|
||||
let rect = this.$el.getBoundingClientRect()
|
||||
if (rect.top < 100) {
|
||||
|
|
|
@ -6,18 +6,26 @@ export default Vue.component('tab-switcher', {
|
|||
name: 'TabSwitcher',
|
||||
data () {
|
||||
return {
|
||||
active: 0
|
||||
active: this.$slots.default.findIndex(_ => _.tag)
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
activateTab(index) {
|
||||
return () => this.active = index;
|
||||
activateTab (index) {
|
||||
return () => {
|
||||
this.active = index
|
||||
}
|
||||
}
|
||||
},
|
||||
render(h) {
|
||||
beforeUpdate () {
|
||||
const currentSlot = this.$slots.default[this.active]
|
||||
if (!currentSlot.tag) {
|
||||
this.active = this.$slots.default.findIndex(_ => _.tag)
|
||||
}
|
||||
},
|
||||
render (h) {
|
||||
const tabs = this.$slots.default
|
||||
.filter(slot => slot.data)
|
||||
.map((slot, index) => {
|
||||
if (!slot.tag) return
|
||||
const classesTab = ['tab']
|
||||
const classesWrapper = ['tab-wrapper']
|
||||
|
||||
|
@ -25,20 +33,24 @@ export default Vue.component('tab-switcher', {
|
|||
classesTab.push('active')
|
||||
classesWrapper.push('active')
|
||||
}
|
||||
|
||||
return (
|
||||
<div class={ classesWrapper.join(' ')}>
|
||||
<button onClick={this.activateTab(index)} class={ classesTab.join(' ') }>{slot.data.attrs.label}</button>
|
||||
</div>
|
||||
)
|
||||
});
|
||||
const contents = this.$slots.default.filter(_=>_.data).map(( slot, index ) => {
|
||||
})
|
||||
|
||||
const contents = this.$slots.default.map((slot, index) => {
|
||||
if (!slot.tag) return
|
||||
const active = index === this.active
|
||||
return (
|
||||
<div class={active ? 'active' : 'hidden'}>
|
||||
{slot}
|
||||
</div>
|
||||
)
|
||||
});
|
||||
})
|
||||
|
||||
return (
|
||||
<div class="tab-switcher">
|
||||
<div class="tabs">
|
||||
|
|
|
@ -5,24 +5,33 @@ import Timeline from '../timeline/timeline.vue'
|
|||
const UserProfile = {
|
||||
created () {
|
||||
this.$store.commit('clearTimeline', { timeline: 'user' })
|
||||
this.$store.commit('clearTimeline', { timeline: 'favorites' })
|
||||
this.$store.dispatch('startFetching', ['user', this.fetchBy])
|
||||
this.$store.dispatch('startFetching', ['favorites', this.fetchBy])
|
||||
if (!this.user.id) {
|
||||
this.$store.dispatch('fetchUser', this.fetchBy)
|
||||
}
|
||||
},
|
||||
destroyed () {
|
||||
this.$store.dispatch('stopFetching', 'user')
|
||||
this.$store.dispatch('stopFetching', 'favorites')
|
||||
},
|
||||
computed: {
|
||||
timeline () {
|
||||
return this.$store.state.statuses.timelines.user
|
||||
},
|
||||
favorites () {
|
||||
return this.$store.state.statuses.timelines.favorites
|
||||
},
|
||||
userId () {
|
||||
return this.$route.params.id || this.user.id
|
||||
},
|
||||
userName () {
|
||||
return this.$route.params.name || this.user.screen_name
|
||||
},
|
||||
isUs () {
|
||||
return this.userId === this.$store.state.users.currentUser.id
|
||||
},
|
||||
friends () {
|
||||
return this.user.friends
|
||||
},
|
||||
|
@ -62,21 +71,28 @@ const UserProfile = {
|
|||
}
|
||||
},
|
||||
watch: {
|
||||
// TODO get rid of this copypasta
|
||||
userName () {
|
||||
if (this.isExternal) {
|
||||
return
|
||||
}
|
||||
this.$store.dispatch('stopFetching', 'user')
|
||||
this.$store.dispatch('stopFetching', 'favorites')
|
||||
this.$store.commit('clearTimeline', { timeline: 'user' })
|
||||
this.$store.commit('clearTimeline', { timeline: 'favorites' })
|
||||
this.$store.dispatch('startFetching', ['user', this.fetchBy])
|
||||
this.$store.dispatch('startFetching', ['favorites', this.fetchBy])
|
||||
},
|
||||
userId () {
|
||||
if (!this.isExternal) {
|
||||
return
|
||||
}
|
||||
this.$store.dispatch('stopFetching', 'user')
|
||||
this.$store.dispatch('stopFetching', 'favorites')
|
||||
this.$store.commit('clearTimeline', { timeline: 'user' })
|
||||
this.$store.commit('clearTimeline', { timeline: 'favorites' })
|
||||
this.$store.dispatch('startFetching', ['user', this.fetchBy])
|
||||
this.$store.dispatch('startFetching', ['favorites', this.fetchBy])
|
||||
},
|
||||
user () {
|
||||
if (this.user.id && !this.user.followers) {
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
<i class="icon-spin3 animate-spin"></i>
|
||||
</div>
|
||||
</div>
|
||||
<Timeline v-if="isUs" :label="$t('user_card.favorites')" :embedded="true" :title="$t('user_profile.favorites_title')" timeline-name="favorites" :timeline="favorites"/>
|
||||
</tab-switcher>
|
||||
</div>
|
||||
<div v-else class="panel user-profile-placeholder">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue