83 lines
2.7 KiB
HTML
83 lines
2.7 KiB
HTML
<div class="timeline" role="feed" aria-label="{{label}}">
|
|
<VirtualList component="{{StatusListItem}}"
|
|
:makeProps
|
|
items="{{$statusIds}}"
|
|
on:scrollToBottom="onScrollToBottom()"
|
|
shown="{{$initialized}}"
|
|
footerComponent="{{LoadingFooter}}"
|
|
showFooter="{{$initialized && $runningUpdate}}"
|
|
realm="{{$currentInstance + '/' + timeline}}"
|
|
on:initializedVisibleItems="initialize()"
|
|
/>
|
|
</div>
|
|
<style>
|
|
.timeline {
|
|
min-height: 60vh;
|
|
}
|
|
</style>
|
|
<script>
|
|
import { store } from '../../_store/store'
|
|
import StatusListItem from './StatusListItem.html'
|
|
import LoadingFooter from './LoadingFooter.html'
|
|
import VirtualList from '../virtualList/VirtualList.html'
|
|
import { timelines } from '../../_static/timelines'
|
|
import { database } from '../../_utils/database/database'
|
|
import { initializeTimeline, fetchStatusesOnScrollToBottom, setupTimeline } from '../../_actions/timeline'
|
|
|
|
export default {
|
|
async oncreate() {
|
|
setupTimeline()
|
|
},
|
|
data: () => ({
|
|
StatusListItem: StatusListItem,
|
|
LoadingFooter: LoadingFooter
|
|
}),
|
|
computed: {
|
|
makeProps: ($currentInstance, timelineType, timelineValue) => async (statusId) => ({
|
|
timelineType: timelineType,
|
|
timelineValue: timelineValue,
|
|
status: await database.getStatus($currentInstance, statusId)
|
|
}),
|
|
label: (timeline, $currentInstance, timelineType, timelineValue) => {
|
|
if (timelines[timeline]) {
|
|
return `${timelines[timeline].label} timeline for ${$currentInstance}`
|
|
}
|
|
|
|
switch (timelineType) {
|
|
case 'tag':
|
|
return `#${timelineValue} timeline for ${$currentInstance}`
|
|
case 'status':
|
|
return 'Status context'
|
|
case 'account':
|
|
return `Account #${timelineValue} on ${$currentInstance}`
|
|
}
|
|
},
|
|
timelineType: (timeline) => {
|
|
return timeline.split('/')[0]
|
|
},
|
|
timelineValue: (timeline) => {
|
|
return timeline.split('/').slice(-1)[0]
|
|
}
|
|
},
|
|
store: () => store,
|
|
components: {
|
|
VirtualList
|
|
},
|
|
methods: {
|
|
initialize() {
|
|
if (this.store.get('initialized') || !this.store.get('statusIds') || !this.store.get('statusIds').length) {
|
|
return
|
|
}
|
|
initializeTimeline()
|
|
},
|
|
onScrollToBottom() {
|
|
if (!this.store.get('initialized') ||
|
|
this.store.get('runningUpdate') ||
|
|
this.get('timelineType') === 'status') { // for status contexts, we've already fetched the whole thread
|
|
return
|
|
}
|
|
fetchStatusesOnScrollToBottom()
|
|
}
|
|
}
|
|
}
|
|
</script> |