mirror of
https://codeberg.org/SafeTwitch/safetwitch.git
synced 2025-01-03 11:20:07 -05:00
Format files
This commit is contained in:
parent
2a519d9b15
commit
3867756fef
6 changed files with 46 additions and 34 deletions
|
@ -108,14 +108,13 @@ export async function followersStreaming(streamers: string[], cursor: number): P
|
||||||
|
|
||||||
const payloadData = streamers.slice(cursor, cursor + 35)
|
const payloadData = streamers.slice(cursor, cursor + 35)
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
streamers: payloadData
|
streamers: payloadData
|
||||||
}
|
}
|
||||||
|
|
||||||
await postEndpoint('api/users/isLive/bulk', payload)
|
await postEndpoint('api/users/isLive/bulk', payload).then((data: string[]) => {
|
||||||
.then((data: string[]) => {
|
res = [...res, ...data]
|
||||||
res = [...res, ...data]
|
})
|
||||||
})
|
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@ -126,7 +125,10 @@ export async function followersStreaming(streamers: string[], cursor: number): P
|
||||||
* @param cursor which 35 streamer chunk to fetch
|
* @param cursor which 35 streamer chunk to fetch
|
||||||
* @returns the streamers in that list that are online
|
* @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
|
// do not make request if no followers
|
||||||
if (streamers.length == 0) {
|
if (streamers.length == 0) {
|
||||||
return []
|
return []
|
||||||
|
@ -136,14 +138,15 @@ export async function getParsedFollowing(streamers: string[], cursor: number): P
|
||||||
|
|
||||||
const payloadData = streamers.slice(cursor, cursor + 35)
|
const payloadData = streamers.slice(cursor, cursor + 35)
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
streamers: payloadData
|
streamers: payloadData
|
||||||
}
|
}
|
||||||
|
|
||||||
await postEndpoint('api/users/followingStreamer/bulk', payload)
|
await postEndpoint('api/users/followingStreamer/bulk', payload).then(
|
||||||
.then((data: FollowingStreamer[]) => {
|
(data: FollowingStreamer[]) => {
|
||||||
res = [...res, ...data]
|
res = [...res, ...data]
|
||||||
})
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
|
@ -206,12 +206,12 @@ export function getFollows(): string[] {
|
||||||
export function getTheme(): string {
|
export function getTheme(): string {
|
||||||
const selectedTheme = localStorage.getItem('theme') || import.meta.env.SAFETWITCH_DEFAULT_THEME
|
const selectedTheme = localStorage.getItem('theme') || import.meta.env.SAFETWITCH_DEFAULT_THEME
|
||||||
|
|
||||||
if (selectedTheme === "") {
|
if (selectedTheme === '') {
|
||||||
return 'light'
|
return 'light'
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure theme exists
|
// Make sure theme exists
|
||||||
const t = themeList.filter(theme => theme.name === selectedTheme)
|
const t = themeList.filter((theme) => theme.name === selectedTheme)
|
||||||
if (t.length === 0) {
|
if (t.length === 0) {
|
||||||
console.error(`Theme ${selectedTheme} does not exist... Perhaps improperly setup instance defaults or improper config?
|
console.error(`Theme ${selectedTheme} does not exist... Perhaps improperly setup instance defaults or improper config?
|
||||||
Stored Theme: ${localStorage.getItem('theme')}
|
Stored Theme: ${localStorage.getItem('theme')}
|
||||||
|
|
|
@ -30,8 +30,8 @@ export interface StreamerData {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FollowingStreamer {
|
export interface FollowingStreamer {
|
||||||
username: string
|
username: string
|
||||||
login: string
|
login: string
|
||||||
pfp: string
|
pfp: string
|
||||||
followers: number
|
followers: number
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ export default {
|
||||||
document.documentElement.scrollTop + window.innerHeight ===
|
document.documentElement.scrollTop + window.innerHeight ===
|
||||||
document.documentElement.offsetHeight
|
document.documentElement.offsetHeight
|
||||||
|
|
||||||
if (!bottomOfWindow) return;
|
if (!bottomOfWindow) return
|
||||||
|
|
||||||
const follows = getFollows()
|
const follows = getFollows()
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ export default {
|
||||||
|
|
||||||
let cursor = this.data.length / 35
|
let cursor = this.data.length / 35
|
||||||
let maxCursor = follows.length / 35
|
let maxCursor = follows.length / 35
|
||||||
if (cursor > maxCursor) return;
|
if (cursor > maxCursor) return
|
||||||
|
|
||||||
let chunk = await getParsedFollowing(follows, cursor)
|
let chunk = await getParsedFollowing(follows, cursor)
|
||||||
this.data = [...this.data, ...chunk]
|
this.data = [...this.data, ...chunk]
|
||||||
|
@ -50,7 +50,7 @@ export default {
|
||||||
const follows = getFollows()
|
const follows = getFollows()
|
||||||
|
|
||||||
window.onscroll = this.getNextFollowingStage
|
window.onscroll = this.getNextFollowingStage
|
||||||
this.data = await getParsedFollowing(follows, 0);
|
this.data = await getParsedFollowing(follows, 0)
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
LoadingScreen,
|
LoadingScreen,
|
||||||
|
|
|
@ -68,14 +68,14 @@ 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)
|
console.log(el)
|
||||||
if (!fullyScrolled) return;
|
if (!fullyScrolled) return
|
||||||
|
|
||||||
if (!this.following) return;
|
if (!this.following) return
|
||||||
let offset = this.following.length / 35
|
let offset = this.following.length / 35
|
||||||
let newFollowers = await followersStreaming(getFollows(), offset)
|
let newFollowers = await followersStreaming(getFollows(), offset)
|
||||||
this.following = [ ...this.following, ...newFollowers]
|
this.following = [...this.following, ...newFollowers]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
|
@ -90,7 +90,7 @@ export default {
|
||||||
this.data = data
|
this.data = data
|
||||||
})
|
})
|
||||||
|
|
||||||
this.following = await followersStreaming(getFollows(), 0)
|
this.following = await followersStreaming(getFollows(), 0)
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
StreamPreviewVue,
|
StreamPreviewVue,
|
||||||
|
@ -107,9 +107,12 @@ export default {
|
||||||
|
|
||||||
<div v-show="data" class="max-w-5xl mx-auto">
|
<div v-show="data" class="max-w-5xl mx-auto">
|
||||||
<div v-if="following && following.length > 0" class="p-2 text-contrast">
|
<div v-if="following && following.length > 0" class="p-2 text-contrast">
|
||||||
<h1 class="font-bold text-5xl">{{ $t("home.following") }}</h1>
|
<h1 class="font-bold text-5xl">{{ $t('home.following') }}</h1>
|
||||||
<p class="text-xl">{{ $t("home.streamersYouFollow") }}</p>
|
<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">
|
<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">
|
<li v-for="streamer in following" :key="streamer" class="inline-block">
|
||||||
<stream-preview-vue :name="streamer"></stream-preview-vue>
|
<stream-preview-vue :name="streamer"></stream-preview-vue>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { ref } from 'vue'
|
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'
|
import type { Settings } from '@/settingsManager'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
Loading…
Reference in a new issue