0
Fork 0
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:
dragongoose 2024-07-11 22:29:07 -04:00
parent cdcf477c42
commit f4195da002
No known key found for this signature in database
GPG key ID: 01397EEC371CDAA5
2 changed files with 13 additions and 9 deletions

View file

@ -106,8 +106,9 @@ export async function followersStreaming(streamers: string[], cursor: number): P
let res: string[] = [] let res: string[] = []
const payloadData = streamers.slice(cursor, cursor + 35) const payloadData = streamers.slice(cursor * 35, (cursor * 35) + 35)
console.log(payloadData)
const payload = { const payload = {
streamers: payloadData streamers: payloadData
} }

View file

@ -15,13 +15,15 @@ export default {
async setup() { async setup() {
let data = ref<CategoryPreviewInterface[]>() let data = ref<CategoryPreviewInterface[]>()
let status = ref<'ok' | 'error'>() let status = ref<'ok' | 'error'>()
let followingStreaming = ref<string[]>()
let following = ref<string[]>() let following = ref<string[]>()
return { return {
data, data,
status, status,
filterTags: '', filterTags: '',
following following,
followingStreaming
} }
}, },
methods: { methods: {
@ -70,13 +72,13 @@ export default {
async handleFollowingScroll(event: UIEvent) { async handleFollowingScroll(event: UIEvent) {
let el = event.target as HTMLUListElement let el = event.target as HTMLUListElement
let fullyScrolled = el.scrollLeft === el.scrollWidth - el.clientWidth let fullyScrolled = el.scrollLeft === el.scrollWidth - el.clientWidth
console.log(el)
if (!fullyScrolled) return if (!fullyScrolled) return
if (!this.following) return if (!this.following) return
let offset = this.following.length / 35
let newFollowers = await followersStreaming(getFollows(), offset) let offset = Math.floor(this.following.length / 35)
this.following = [...this.following, ...newFollowers] console.log(offset)
let newFollowers = await followersStreaming(this.following, offset)
this.followingStreaming = [...this.following, ...newFollowers]
} }
}, },
async mounted() { async mounted() {
@ -91,7 +93,8 @@ export default {
this.data = data this.data = data
}) })
this.following = await followersStreaming(getFollows(), 0) this.followingStreaming = await followersStreaming(getFollows(), 0)
this.following = await getFollows()
}, },
components: { components: {
StreamPreviewVue, 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" class="flex flex-nowrap justify-begin overflow-x-scroll overflow-y-hidden space-x-2 mt-1 h-[19rem] items-center"
@scroll="handleFollowingScroll" @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> <stream-preview-vue :name="streamer"></stream-preview-vue>
</li> </li>
</ul> </ul>