mirror of
https://codeberg.org/SafeTwitch/safetwitch.git
synced 2024-12-22 05:12:57 -05:00
This was hideous code.. Fix stream previews in following tab looping over and over (it was more than a division issue) #100)
This commit is contained in:
parent
cdcf477c42
commit
f4195da002
2 changed files with 13 additions and 9 deletions
|
@ -106,8 +106,9 @@ export async function followersStreaming(streamers: string[], cursor: number): P
|
|||
|
||||
let res: string[] = []
|
||||
|
||||
const payloadData = streamers.slice(cursor, cursor + 35)
|
||||
const payloadData = streamers.slice(cursor * 35, (cursor * 35) + 35)
|
||||
|
||||
console.log(payloadData)
|
||||
const payload = {
|
||||
streamers: payloadData
|
||||
}
|
||||
|
|
|
@ -15,13 +15,15 @@ export default {
|
|||
async setup() {
|
||||
let data = ref<CategoryPreviewInterface[]>()
|
||||
let status = ref<'ok' | 'error'>()
|
||||
let followingStreaming = ref<string[]>()
|
||||
let following = ref<string[]>()
|
||||
|
||||
return {
|
||||
data,
|
||||
status,
|
||||
filterTags: '',
|
||||
following
|
||||
following,
|
||||
followingStreaming
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
@ -70,13 +72,13 @@ export default {
|
|||
async handleFollowingScroll(event: UIEvent) {
|
||||
let el = event.target as HTMLUListElement
|
||||
let fullyScrolled = el.scrollLeft === el.scrollWidth - el.clientWidth
|
||||
console.log(el)
|
||||
if (!fullyScrolled) return
|
||||
|
||||
if (!this.following) return
|
||||
let offset = this.following.length / 35
|
||||
let newFollowers = await followersStreaming(getFollows(), offset)
|
||||
this.following = [...this.following, ...newFollowers]
|
||||
|
||||
let offset = Math.floor(this.following.length / 35)
|
||||
console.log(offset)
|
||||
let newFollowers = await followersStreaming(this.following, offset)
|
||||
this.followingStreaming = [...this.following, ...newFollowers]
|
||||
}
|
||||
},
|
||||
async mounted() {
|
||||
|
@ -91,7 +93,8 @@ export default {
|
|||
this.data = data
|
||||
})
|
||||
|
||||
this.following = await followersStreaming(getFollows(), 0)
|
||||
this.followingStreaming = await followersStreaming(getFollows(), 0)
|
||||
this.following = await getFollows()
|
||||
},
|
||||
components: {
|
||||
StreamPreviewVue,
|
||||
|
@ -118,7 +121,7 @@ export default {
|
|||
class="flex flex-nowrap justify-begin overflow-x-scroll overflow-y-hidden space-x-2 mt-1 h-[19rem] items-center"
|
||||
@scroll="handleFollowingScroll"
|
||||
>
|
||||
<li v-for="streamer in following" :key="streamer" class="inline-block">
|
||||
<li v-for="streamer in followingStreaming" :key="streamer" class="inline-block">
|
||||
<stream-preview-vue :name="streamer"></stream-preview-vue>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in a new issue