Skip to content

Commit c024302

Browse files
committed
Fix fetching player stats
1 parent f6ffc90 commit c024302

File tree

4 files changed

+12
-28
lines changed

4 files changed

+12
-28
lines changed

backend/build.gradle.kts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,11 @@ kotlin {
2828
}
2929

3030
tasks {
31-
/*
32-
val copyFrontend = create<Copy>("copyFrontend") {
33-
val frontend = project(":frontend")
34-
35-
inputs.dir(frontend.projectDir)
36-
37-
from(frontend.file("dist"))
38-
into(layout.buildDirectory.dir("resources/main/frontend"))
39-
40-
dependsOn(":frontend:generate")
41-
}
42-
*/
43-
4431
compileKotlin {
4532
dependsOn(clean)
4633
}
4734

48-
/*
49-
create<Jar>("devJar") {
50-
finalizedBy(copyFrontend)
51-
}
52-
*/
53-
5435
shadowJar {
5536
archiveFileName = "RoxyMC-website.jar"
56-
57-
//dependsOn(copyFrontend)
5837
}
59-
}
38+
}

frontend/.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
NUXT_PUBLIC_API_BASE=http://localhost:8080
1+
NUXT_PUBLIC_API_BASE=http://localhost:8080

frontend/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ tasks {
2929
args = listOf("run", "generate")
3030
dependsOn(postInstall)
3131
}
32-
}
32+
}

frontend/src/pages/player-stats/index.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ const {
3131
status,
3232
data: playersStats
3333
} = await useLazyAsyncData(async () => {
34+
fetching.value = true
3435
const response = await $fetch.raw(`${apiBase}/player-stats?search=${searchInput.value}`)
36+
fetching.value = false
3537
3638
totalCount = parseInt(response.headers.get("X-Total-Count") || response._data.length.toString())
3739
@@ -43,7 +45,7 @@ const {
4345
4446
const onScroll = () => {
4547
if (!pageArea.value) return
46-
if (window.scrollY + window.innerHeight < pageArea.value.offsetHeight + pageArea.value.offsetTop) return;
48+
if (window.scrollY + window.innerHeight < pageArea.value.offsetHeight + pageArea.value.offsetTop) return
4749
4850
debounce(async () => {
4951
const offset = getOffset()
@@ -63,6 +65,10 @@ onMounted(() => {
6365
6466
onUnmounted(() => {
6567
window.removeEventListener("scroll", onScroll)
68+
if (timeoutId) {
69+
clearTimeout(timeoutId);
70+
}
71+
playersStats.value = []
6672
})
6773
6874
const input = (e: InputEvent) => {
@@ -72,12 +78,11 @@ const input = (e: InputEvent) => {
7278
7379
const search = (input: string) => {
7480
searchInput.value = input
81+
playersStats.value = []
7582
execute()
7683
}
7784
7885
const getOffset = (): number => status.value === "success" ? playersStats.value?.length || 0 : 0
79-
80-
const isFetching = (): boolean => !playersStats.value || fetching.value
8186
</script>
8287

8388
<template>
@@ -95,7 +100,7 @@ const isFetching = (): boolean => !playersStats.value || fetching.value
95100
<div v-if="playersStats" class="flex flex-wrap gap-4">
96101
<PlayerCard v-for="stats in playersStats" :player-stats="stats"/>
97102
</div>
98-
<div v-if="isFetching()" class="flex justify-center">
103+
<div v-if="fetching" class="flex justify-center">
99104
<SpinningWheel/>
100105
</div>
101106
</div>

0 commit comments

Comments
 (0)