1
0
mirror of https://github.com/nolanlawson/pinafore synced 2024-12-11 09:45:24 +01:00
Pinafore-Web-Client-Frontend/routes/_components/Timeline.html
2018-01-17 00:59:15 -08:00

51 lines
1.2 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, push } from 'svelte-extras'
import { mark, stop } from '../_utils/marks'
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,
push: push,
addMoreItems() {
mark('addMoreItems')
let statuses = this.get('statuses')
if (statuses) {
let itemsToAdd = createData()
this.splice('statuses', statuses.length, 0, ...itemsToAdd)
}
stop('addMoreItems')
}
}
}
</script>