Compare commits

...

1 commit

Author SHA1 Message Date
Shpuld Shpuldson
1e296e79a1 move pinned statuses from user TL storage to separate pins 2020-02-01 19:33:27 +02:00
3 changed files with 9 additions and 26 deletions

View file

@ -3,19 +3,6 @@ import timelineFetcher from '../../services/timeline_fetcher/timeline_fetcher.se
import Conversation from '../conversation/conversation.vue' import Conversation from '../conversation/conversation.vue'
import { throttle, keyBy } from 'lodash' import { throttle, keyBy } from 'lodash'
export const getExcludedStatusIdsByPinning = (statuses, pinnedStatusIds) => {
const ids = []
if (pinnedStatusIds && pinnedStatusIds.length > 0) {
for (let status of statuses) {
if (!pinnedStatusIds.includes(status.id)) {
break
}
ids.push(status.id)
}
}
return ids
}
const Timeline = { const Timeline = {
props: [ props: [
'timeline', 'timeline',
@ -60,14 +47,11 @@ const Timeline = {
footer: ['timeline-footer'].concat(!this.embedded ? ['panel-footer'] : []) footer: ['timeline-footer'].concat(!this.embedded ? ['panel-footer'] : [])
} }
}, },
// id map of statuses which need to be hidden in the main list due to pinning logic
excludedStatusIdsObject () {
const ids = getExcludedStatusIdsByPinning(this.timeline.visibleStatuses, this.pinnedStatusIds)
// Convert id array to object
return keyBy(ids)
},
pinnedStatusIdsObject () { pinnedStatusIdsObject () {
return keyBy(this.pinnedStatusIds) return keyBy(this.pinnedStatusIds)
},
pinnedStatuses () {
return this.$store.state.statuses.timelines.pins.visibleStatuses.filter(status => status.user.id === this.userId)
} }
}, },
components: { components: {

View file

@ -35,12 +35,11 @@
</div> </div>
<div :class="classes.body"> <div :class="classes.body">
<div class="timeline"> <div class="timeline">
<template v-for="statusId in pinnedStatusIds"> <template v-for="status in pinnedStatuses">
<conversation <conversation
v-if="timeline.statusesObject[statusId]" :key="status.id + '-pinned'"
:key="statusId + '-pinned'"
class="status-fadein" class="status-fadein"
:status-id="statusId" :status-id="status.id"
:collapsable="true" :collapsable="true"
:pinned-status-ids-object="pinnedStatusIdsObject" :pinned-status-ids-object="pinnedStatusIdsObject"
:in-profile="inProfile" :in-profile="inProfile"
@ -49,7 +48,6 @@
</template> </template>
<template v-for="status in timeline.visibleStatuses"> <template v-for="status in timeline.visibleStatuses">
<conversation <conversation
v-if="!excludedStatusIdsObject[status.id]"
:key="status.id" :key="status.id"
class="status-fadein" class="status-fadein"
:status-id="status.id" :status-id="status.id"

View file

@ -61,7 +61,8 @@ export const defaultState = () => ({
publicAndExternal: emptyTl(), publicAndExternal: emptyTl(),
friends: emptyTl(), friends: emptyTl(),
tag: emptyTl(), tag: emptyTl(),
dms: emptyTl() dms: emptyTl(),
pins: emptyTl()
} }
}) })
@ -630,7 +631,7 @@ const statuses = {
}, },
fetchPinnedStatuses ({ rootState, dispatch }, userId) { fetchPinnedStatuses ({ rootState, dispatch }, userId) {
rootState.api.backendInteractor.fetchPinnedStatuses({ id: userId }) rootState.api.backendInteractor.fetchPinnedStatuses({ id: userId })
.then(statuses => dispatch('addNewStatuses', { statuses, timeline: 'user', userId, showImmediately: true, noIdUpdate: true })) .then(statuses => dispatch('addNewStatuses', { statuses, timeline: 'pins', userId, showImmediately: true, noIdUpdate: true }))
}, },
pinStatus ({ rootState, dispatch }, statusId) { pinStatus ({ rootState, dispatch }, statusId) {
return rootState.api.backendInteractor.pinOwnStatus({ id: statusId }) return rootState.api.backendInteractor.pinOwnStatus({ id: statusId })