Skip to content

Commit

Permalink
feat: reactivity fix for Leaderboard component
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbrayo committed Aug 28, 2024
1 parent 7b29357 commit fdda1cd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/components/Leaderboard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { ref, onMounted, computed, type ComputedRef } from 'vue'
import { useLeaderboardStore } from '@/stores/leaderboard'
import { type ScreenTimeSummary } from '@/types'
import AWLHeader from '@/components/Header.vue'
Expand All @@ -36,8 +36,9 @@ onMounted(async () => {
try {
const { fetchLeaderboardData, leaderboardData } = useLeaderboardStore()
fetchLeaderboardData()
leaderboardData?.sort((a, b) => b.total - a.total)
entries.value = leaderboardData
const leaderboardDataRef: ComputedRef = computed(() => leaderboardData)
leaderboardDataRef.value.sort((a: { total: number }, b: { total: number }) => b.total - a.total)
entries.value = leaderboardDataRef.value
} catch (error) {
console.error(error)
}
Expand Down

0 comments on commit fdda1cd

Please sign in to comment.