0
Fork 0
mirror of https://codeberg.org/SafeTwitch/safetwitch.git synced 2024-12-22 05:12:57 -05:00

Format files

This commit is contained in:
dragongoose 2024-02-12 22:11:38 -05:00
parent 2a519d9b15
commit 3867756fef
No known key found for this signature in database
GPG key ID: 01397EEC371CDAA5
6 changed files with 46 additions and 34 deletions

View file

@ -108,14 +108,13 @@ export async function followersStreaming(streamers: string[], cursor: number): P
const payloadData = streamers.slice(cursor, cursor + 35)
const payload = {
streamers: payloadData
}
const payload = {
streamers: payloadData
}
await postEndpoint('api/users/isLive/bulk', payload)
.then((data: string[]) => {
res = [...res, ...data]
})
await postEndpoint('api/users/isLive/bulk', payload).then((data: string[]) => {
res = [...res, ...data]
})
return res
}
@ -126,7 +125,10 @@ export async function followersStreaming(streamers: string[], cursor: number): P
* @param cursor which 35 streamer chunk to fetch
* @returns the streamers in that list that are online
*/
export async function getParsedFollowing(streamers: string[], cursor: number): Promise<FollowingStreamer[]> {
export async function getParsedFollowing(
streamers: string[],
cursor: number
): Promise<FollowingStreamer[]> {
// do not make request if no followers
if (streamers.length == 0) {
return []
@ -136,14 +138,15 @@ export async function getParsedFollowing(streamers: string[], cursor: number): P
const payloadData = streamers.slice(cursor, cursor + 35)
const payload = {
streamers: payloadData
}
const payload = {
streamers: payloadData
}
await postEndpoint('api/users/followingStreamer/bulk', payload)
.then((data: FollowingStreamer[]) => {
await postEndpoint('api/users/followingStreamer/bulk', payload).then(
(data: FollowingStreamer[]) => {
res = [...res, ...data]
})
}
)
return res
}
}

View file

@ -206,12 +206,12 @@ export function getFollows(): string[] {
export function getTheme(): string {
const selectedTheme = localStorage.getItem('theme') || import.meta.env.SAFETWITCH_DEFAULT_THEME
if (selectedTheme === "") {
if (selectedTheme === '') {
return 'light'
}
// Make sure theme exists
const t = themeList.filter(theme => theme.name === selectedTheme)
const t = themeList.filter((theme) => theme.name === selectedTheme)
if (t.length === 0) {
console.error(`Theme ${selectedTheme} does not exist... Perhaps improperly setup instance defaults or improper config?
Stored Theme: ${localStorage.getItem('theme')}

View file

@ -30,8 +30,8 @@ export interface StreamerData {
}
export interface FollowingStreamer {
username: string
login: string
pfp: string
followers: number
username: string
login: string
pfp: string
followers: number
}

View file

@ -27,8 +27,8 @@ export default {
let bottomOfWindow =
document.documentElement.scrollTop + window.innerHeight ===
document.documentElement.offsetHeight
if (!bottomOfWindow) return;
if (!bottomOfWindow) return
const follows = getFollows()
@ -40,7 +40,7 @@ export default {
let cursor = this.data.length / 35
let maxCursor = follows.length / 35
if (cursor > maxCursor) return;
if (cursor > maxCursor) return
let chunk = await getParsedFollowing(follows, cursor)
this.data = [...this.data, ...chunk]
@ -50,7 +50,7 @@ export default {
const follows = getFollows()
window.onscroll = this.getNextFollowingStage
this.data = await getParsedFollowing(follows, 0);
this.data = await getParsedFollowing(follows, 0)
},
components: {
LoadingScreen,

View file

@ -68,14 +68,14 @@ export default {
},
async handleFollowingScroll(event: UIEvent) {
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)
this.following = [ ...this.following, ...newFollowers]
this.following = [...this.following, ...newFollowers]
}
},
async mounted() {
@ -90,7 +90,7 @@ export default {
this.data = data
})
this.following = await followersStreaming(getFollows(), 0)
this.following = await followersStreaming(getFollows(), 0)
},
components: {
StreamPreviewVue,
@ -107,9 +107,12 @@ export default {
<div v-show="data" class="max-w-5xl mx-auto">
<div v-if="following && following.length > 0" class="p-2 text-contrast">
<h1 class="font-bold text-5xl">{{ $t("home.following") }}</h1>
<p class="text-xl">{{ $t("home.streamersYouFollow") }}</p>
<ul class="flex flex-nowrap justify-begin overflow-x-scroll overflow-y-hidden space-x-2 mt-1 h-[19rem] items-center" @scroll="handleFollowingScroll">
<h1 class="font-bold text-5xl">{{ $t('home.following') }}</h1>
<p class="text-xl">{{ $t('home.streamersYouFollow') }}</p>
<ul
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">
<stream-preview-vue :name="streamer"></stream-preview-vue>
</li>

View file

@ -1,6 +1,12 @@
<script lang="ts">
import { ref } from 'vue'
import { getDefaultSettings, syncUserSettings, setLanguage, themeList, getTheme } from '@/settingsManager'
import {
getDefaultSettings,
syncUserSettings,
setLanguage,
themeList,
getTheme
} from '@/settingsManager'
import type { Settings } from '@/settingsManager'
export default {