Skip to content

Commit

Permalink
fix rank
Browse files Browse the repository at this point in the history
  • Loading branch information
arily committed Mar 7, 2024
1 parent d349d28 commit cfae0f6
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/store/userpage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,32 @@ export default defineStore('userpage', () => {

const currentRankingSystem = shallowRef<ReturnType<typeof _computeRankingSystem> | null>(null)

let dispose: WatchStopHandle = () => {}
let dispose: WatchStopHandle[] = []

async function init() {
dispose.forEach(cb => cb())

const route = useRoute('user-handle')
try {
const u = await app.$client.user.userpage.query({
handle: `${route.params.handle}`,
})
user.value = u
dispose()

setSwitcher(u.preferredMode)
currentStatistic.value = _computeStatistic()
currentRankingSystem.value = _computeRankingSystem()
error.value = null

dispose = watch([
() => switcher.mode,
() => switcher.ruleset,
], refresh)
dispose = [
watch([
() => switcher.mode,
() => switcher.ruleset,
], refresh),
watch(() => switcher.rankingSystem, () => {
currentRankingSystem.value = _computeRankingSystem()
}),
]
}
catch (e) {
console.error(e)
Expand Down

0 comments on commit cfae0f6

Please sign in to comment.