Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
arily committed Jul 10, 2023
1 parent 6fa0d23 commit 23d0cb4
Show file tree
Hide file tree
Showing 35 changed files with 98 additions and 63 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,5 @@ module.exports = {
tuples: 'always-multiline',
}],
'@typescript-eslint/no-namespace': 'off',
'@typescript-eslint/consistent-type-imports': 'off',
},
}
3 changes: 2 additions & 1 deletion src/common/utils/guards.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BeatmapSource, Beatmapset } from '~/def/beatmap'
import type { Beatmapset } from '~/def/beatmap'
import { BeatmapSource } from '~/def/beatmap'

export function isString(input: unknown): input is string {
return typeof input === 'string'
Expand Down
4 changes: 3 additions & 1 deletion src/common/utils/map.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {
import type {
BeatmapSource,
BeatmapWithMeta,
NormalBeatmapWithMeta,
} from '~/def/beatmap'
import {
RankingStatus,
} from '~/def/beatmap'

Expand Down
3 changes: 2 additions & 1 deletion src/common/utils/privilege.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { UserEssential, UserPrivilege } from '~/def/user'
import type { UserEssential } from '~/def/user'
import { UserPrivilege } from '~/def/user'

export function calcUserPrivilege(user: UserEssential<unknown>) {
const admin = user.roles.includes(UserPrivilege.Admin)
Expand Down
6 changes: 3 additions & 3 deletions src/components/T/responsive-modal.client.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import type { TModal } from '#components'
import { TModal } from '#components'
type I = InstanceType<typeof TModal>
const e = shallowRef<I>()
Expand All @@ -14,9 +14,9 @@ defineExpose({
</script>

<template>
<t-modal ref="e" v-slot="props">
<TModal ref="e" v-slot="props">
<div response-modal class="h-[100dvh] md:h-auto flex items-end pb-8">
<slot v-bind="props" />
</div>
</t-modal>
</TModal>
</template>
3 changes: 2 additions & 1 deletion src/components/app/score-list-item.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { RankingSystemScore, StableMod } from '~/def/score'
import type { RankingSystemScore } from '~/def/score'
import { StableMod } from '~/def/score'
import type { ActiveMode, ActiveRuleset, LeaderboardPPRankingSystem, LeaderboardRankingSystem, LeaderboardScoreRankingSystem } from '~/def/common'
import {
Rank,
Expand Down
4 changes: 2 additions & 2 deletions src/components/content/editor/extensions/variable.shared.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Editor, InputRule, PasteRule } from '@tiptap/core'
import { NodeType } from 'prosemirror-model'
import type { Editor, InputRule, PasteRule } from '@tiptap/core'
import type { NodeType } from 'prosemirror-model'

import useEditorVariables from '~/composables/useEditorVariables'

Expand Down
6 changes: 3 additions & 3 deletions src/components/content/editor/insert-image.client.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script setup lang="ts">
import type { Editor } from '@tiptap/vue-3'
import type { TResponsiveModal } from '#components'
import { TResponsiveModal } from '#components'
const props = defineProps<{
editor: Editor
Expand Down Expand Up @@ -36,7 +36,7 @@ defineExpose({
</script>

<template>
<t-responsive-modal ref="modal" v-slot="{ closeModal }" class="my-auto max-w-full" @closed="reset">
<TResponsiveModal ref="modal" v-slot="{ closeModal }" class="my-auto max-w-full" @closed="reset">
<div class="card bg-base-100/50 shadow-lg w-full">
<form action="#" @submit.prevent="setLink(closeModal)">
<div class="card-body w-96">
Expand Down Expand Up @@ -90,7 +90,7 @@ defineExpose({
</div>
</form>
</div>
</t-responsive-modal>
</TResponsiveModal>
</template>

<style scoped>
Expand Down
2 changes: 1 addition & 1 deletion src/composables/useEditorVariables.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LeaderboardRankingSystem } from '~/def/common'
import type { LeaderboardRankingSystem } from '~/def/common'

const variables = new Map<string, Template>()

Expand Down
3 changes: 2 additions & 1 deletion src/composables/useUserRoleColor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { UserEssential, UserPrivilege } from '~/def/user'
import type { UserEssential } from '~/def/user'
import { UserPrivilege } from '~/def/user'

// https://hypercolor.dev/
export default function (user: UserEssential<unknown>) {
Expand Down
2 changes: 1 addition & 1 deletion src/def/score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type {
LeaderboardRankingSystem,
PPRankingSystem,
} from './common'
import { Mode } from '.'
import type { Mode } from '.'

export enum Grade {
F = 'f',
Expand Down
2 changes: 1 addition & 1 deletion src/def/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
LeaderboardScoreRankingSystem,
PPRankingSystem,
} from './common'
import { Grade } from './score'
import type { Grade } from './score'

export interface BaseRank {
rank?: number
Expand Down
2 changes: 1 addition & 1 deletion src/def/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
} from './common'
import type { UserModeRulesetStatistics } from './statistics'
import type { UserRelationship } from './user-relationship'
import { ArticleProvider } from '$base/server'
import type { ArticleProvider } from '$base/server'

export enum Scope {
Self,
Expand Down
2 changes: 1 addition & 1 deletion src/pages/article/edit.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { parse, stringify } from 'devalue'
import { Scope, UserPrivilege } from '~/def/user'
import { ContentEditor } from '#components'
import type { ContentEditor } from '#components'
import type { ArticleProvider } from '$base/server'
definePageMeta({
Expand Down
4 changes: 2 additions & 2 deletions src/pages/auth/register.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import md5 from 'md5'
import { TRPCClientError } from '@trpc/client'
import type { TRPCClientError } from '@trpc/client'
import { Feature } from '~/def/features'
import { AppRouter } from '~/server/trpc/routers'
import type { AppRouter } from '~/server/trpc/routers'
import { useSession } from '~/store/session'
import { features } from '$active'
Expand Down
4 changes: 2 additions & 2 deletions src/pages/beatmapset/[id].vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { BeatmapSource } from '~/def/beatmap'
import { Mode } from '~/def'
import type { AppScoresRankingSystemSwitcher } from '#components'
import { AppScoresRankingSystemSwitcher } from '#components'
import type { Label } from '~/composables/useLinks'
definePageMeta({
Expand Down Expand Up @@ -344,7 +344,7 @@ async function update() {
</div>
</div>
<div class="container custom-container mx-auto mt-4">
<app-scores-ranking-system-switcher
<AppScoresRankingSystemSwitcher
ref="scoreRS" v-model="switcher.rankingSystem" :mode="switcher.mode"
:ruleset="switcher.ruleset" class="mx-auto" @update:model-value="update"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/me/relations.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { UserEssential } from '~/def/user'
import type { UserEssential } from '~/def/user'
import type { UserRelationship } from '~/def/user-relationship'
import { Relationship } from '~/def'
import { useSession } from '~/store/session'
Expand Down
30 changes: 17 additions & 13 deletions src/pages/me/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import 'vue-advanced-cropper/dist/style.css'
import md5 from 'md5'
import { Client, OS } from '~/def/device'
import type { ContentEditor, TModal, TResponsiveModal } from '#components'
import { TModal, TResponsiveModal } from '#components'
import type { ContentEditor } from '#components'
import { useSession } from '~/store/session'
import { ArticleProvider } from '$base/server/article'
import type { ArticleProvider } from '$base/server/article'
import { UserPrivilege } from '~/def/user'
// eslint-disable-next-line antfu/no-const-enum
Expand All @@ -34,8 +35,8 @@ useHead({
titleTemplate: `Settings - ${config.title}`,
})
const { data: user, refresh } = await useAsyncData(() => app$.$client.me.settings.query())
const { data: sessions } = await useAsyncData(() => app$.$client.me.sessions.query())
const { data: user, refresh: refreshSettings } = await useAsyncData(() => app$.$client.me.settings.query())
const { data: sessions, refresh: refreshSession, pending: pendingSession } = await useAsyncData(() => app$.$client.me.sessions.query())
if (!user.value) {
await navigateTo({
Expand Down Expand Up @@ -98,7 +99,7 @@ async function saveAvatar() {
uploadingAvatarStat.value = UploadingAvatarStatus.Succeed
newAvatarURL.value = url
session.setAvatarTimestamp()
await refresh()
await refreshSettings()
editor.value?.reload()
}
async function updateUserSettings() {
Expand Down Expand Up @@ -195,11 +196,16 @@ function resetAvatar() {
newAvatarURL.value = undefined
uploadingAvatarStat.value = UploadingAvatarStatus.Idle
}
async function kickSession(session: string) {
await app$.$client.me.kickSession.mutate({ session })
refreshSession()
}
</script>

<template>
<section v-if="user" class="container mx-auto custom-container">
<t-responsive-modal
<TResponsiveModal
ref="changeAvatar"
v-slot="{ closeModal }"
class="my-auto"
Expand Down Expand Up @@ -280,9 +286,9 @@ function resetAvatar() {
{{ uploadingAvatarStat === UploadingAvatarStatus.Succeed ? "Done" : "Cancel" }}
</t-button>
</div>
</t-responsive-modal>
</TResponsiveModal>

<t-modal ref="changePassword" v-slot="{ closeModal }" class="my-auto">
<TModal ref="changePassword" v-slot="{ closeModal }" class="my-auto">
<div class="card bg-base-100 shadow-lg">
<form action="#" @submit.prevent="updatePassword(closeModal)">
<div class="card-body w-96">
Expand Down Expand Up @@ -343,7 +349,7 @@ function resetAvatar() {
</div>
</form>
</div>
</t-modal>
</TModal>
<div class="container mx-auto">
<div class="flex justify-between p-2 items-end">
<div class="text-3xl font-bold">
Expand Down Expand Up @@ -436,7 +442,7 @@ function resetAvatar() {
</div>
<div>
<div class="font-bold">
{{ OS[session.OS] }}
{{ OS[session.OS] }} <span v-if="session.current" class="badge badge-ghost badge-sm">Current Session</span>
</div>
<div class="text-sm opacity-50">
{{ Client[session.client] }}
Expand All @@ -446,11 +452,9 @@ function resetAvatar() {
</td>
<td>
{{ session.lastActivity.toLocaleString() }}
<br>
<span v-if="session.current" class="badge badge-ghost badge-sm">Current Session</span>
</td>
<th>
<button class="btn btn-ghost btn-xs">
<button class="btn btn-ghost btn-xs" :disabled="pendingSession || session.current" :class="{ loading: pendingSession }" @click.prevent="kickSession(id)">
Kick
</button>
</th>
Expand Down
2 changes: 1 addition & 1 deletion src/server/backend/$base/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ActiveMode, ActiveRuleset, AvailableRuleset, LeaderboardRankingSystem, RankingSystem } from '~/def/common'
import { Feature } from '~/def/features'
import type { Feature } from '~/def/features'
import type {
HasLeaderboardRankingSystem,
HasRankingSystem,
Expand Down
2 changes: 1 addition & 1 deletion src/server/backend/$base/log/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createLogger, format, transports } from 'winston'
import Transport from 'winston-transport'
import type Transport from 'winston-transport'

const { combine, timestamp, json, printf } = format

Expand Down
6 changes: 3 additions & 3 deletions src/server/backend/$base/server/article/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import fs from 'node:fs/promises'
import { isAbsolute, join, relative, resolve } from 'node:path'
import { PathLike } from 'node:fs'
import type { PathLike } from 'node:fs'
import * as BSON from 'bson'
import type { JSONContent as TipTapJSONContent } from '@tiptap/core'
import { generateHTML } from '@tiptap/html'

import { DeepPartial } from '@trpc/server'
import type { DeepPartial } from '@trpc/server'
import { compileGraph, createPipeline, hops } from 'schema-evolution'
import dirTree from 'directory-tree'

import { latest, paths, v0, versions } from './v'
import { UserEssential, UserPrivilege } from '~/def/user'
import type { UserEssential, UserPrivilege } from '~/def/user'
import useEditorExtensions from '~/composables/useEditorExtensionsServer'
import { UserRelationProvider } from '$active/server'
import { Logger } from '$base/log'
Expand Down
4 changes: 2 additions & 2 deletions src/server/backend/$base/server/session.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { v4 } from 'uuid'
import { match } from 'switch-pattern'
import { Logger } from '$base/log'
import { Client, OS } from '~/def/device'
import type { Client, OS } from '~/def/device'

const logger = Logger.child({ label: 'session' })

Expand Down Expand Up @@ -33,7 +33,7 @@ export interface SessionStore<TSessionId extends string | symbol, TSession exten
set(key: TSessionId, value: TSession): PromiseLike<TSessionId>
destroy(key: TSessionId): PromiseLike<boolean>
forEach(cb: (session: TSession, id: TSessionId) => void | PromiseLike<void>): PromiseLike<void>
findAll(query: Pick<TSession, 'OS' | 'userId'>): PromiseLike<Record<TSessionId, TSession>>
findAll(query: Partial<Pick<TSession, 'OS' | 'userId'>>): PromiseLike<Record<TSessionId, TSession>>
}
export const config = {
expire: 1000 * 60 * 60,
Expand Down
2 changes: 1 addition & 1 deletion src/server/backend/bancho.py/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Feature } from '~/def/features'
import type { Feature } from '~/def/features'

export { modes, rulesets } from '~/def'

Expand Down
3 changes: 2 additions & 1 deletion src/server/backend/bancho.py/server/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { getPrismaClient } from './source/prisma'
import type { Tag } from '~/def/search'

import type { MapProvider as Base } from '$base/server'
import { BeatmapSource, Beatmapset, RankingStatus } from '~/def/beatmap'
import type { BeatmapSource, Beatmapset } from '~/def/beatmap'
import { RankingStatus } from '~/def/beatmap'

export class MapProvider implements Base<Id> {
static idToString = idToString
Expand Down
3 changes: 2 additions & 1 deletion src/server/backend/bancho.py/server/source/redis.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { RedisClientType, createClient } from 'redis'
import type { RedisClientType } from 'redis'
import { createClient } from 'redis'
import { Logger } from '../../log'
import { env } from '~/server/env'

Expand Down
3 changes: 2 additions & 1 deletion src/server/backend/bancho.py/server/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ import { userNotFound } from '~/server/trpc/messages'
import type { UserProvider as Base } from '$base/server'
import type { ActiveMode, ActiveRuleset, LeaderboardRankingSystem } from '~/def/common'

import { UserEssential, UserOptional, UserStatistic, UserStatus } from '~/def/user'
import type { UserEssential, UserOptional, UserStatistic } from '~/def/user'
import { UserStatus } from '~/def/user'
import { Mode, Rank, Ruleset } from '~/def'

const logger = Logger.child({ label: 'user' })
Expand Down
2 changes: 1 addition & 1 deletion src/server/backend/bancho.py/transforms/relations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RelationshipType } from 'prisma-client-bancho-py'
import type { RelationshipType } from 'prisma-client-bancho-py'
import { Relationship } from '~/def'

export function toBanchoPyRelationType(relation: Relationship): RelationshipType {
Expand Down
5 changes: 3 additions & 2 deletions src/server/backend/bancho.py/transforms/score.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { createHitCount } from './create-hit-count'
import { toMods } from '.'

import type { AbleToTransformToScores } from './index'
import { BeatmapSource, RankingStatus } from '~/def/beatmap'
import type { BeatmapSource } from '~/def/beatmap'
import { RankingStatus } from '~/def/beatmap'
import type {
ActiveMode,
ActiveRuleset,
LeaderboardRankingSystem,
PPRankingSystem,
} from '~/def/common'
import { Grade, RankingSystemScore, RulesetScore } from '~/def/score'
import type { Grade, RankingSystemScore, RulesetScore } from '~/def/score'
import { Rank } from '~/def'

export function toScore<RS extends PPRankingSystem>({
Expand Down
Loading

0 comments on commit 23d0cb4

Please sign in to comment.