pinafore/routes/_components/Timeline.html
2018-01-16 23:16:15 -08:00

47 lines
1.1 KiB
HTML

<div class="timeline">
<VirtualList component="{{StatusListItem}}"
items="{{statuses}}"
on:scrollToBottom="addMoreItems()" />
</div>
<style>
.timeline {
min-height: 50vh;
}
</style>
<script>
import { store } from '../_utils/store'
import { getHomeTimeline } from '../_utils/mastodon/oauth'
import fixture from '../_utils/fixture.json'
import StatusListItem from './StatusListItem.html'
import VirtualList from './VirtualList.html'
import { splice } from 'svelte-extras'
let i = -1
const createData = () => fixture.slice(0, 20).map(_ => ({
key: `${++i}`,
props: _
}))
export default {
data: () => ({
target: 'home',
statuses: createData(),
StatusListItem: StatusListItem
}),
store: () => store,
components: {
VirtualList
},
methods: {
splice: splice,
addMoreItems() {
console.log('addMoreItems')
let statuses = this.get('statuses')
if (statuses) {
this.splice('statuses', statuses.length, 0, ...createData())
}
}
}
}
</script>