fix(ts): replace `import { type ...` with `import type { ...` to babysit ts/vite?

This commit is contained in:
upsiflu 2025-02-12 14:29:32 +01:00
parent 7c448d44d6
commit 283b017f59
6 changed files with 38 additions and 28 deletions

View File

@ -4,7 +4,7 @@ import { watchEffect, computed, onMounted, nextTick } from 'vue'
import { type QueueTrack, useQueue } from '~/composables/audio/queue' import { type QueueTrack, useQueue } from '~/composables/audio/queue'
import { useStore } from '~/store' import { useStore } from '~/store'
import useLogger from '~/composables/useLogger' import useLogger from '~/composables/useLogger'
import { useLocalStorage, useStyleTag, useIntervalFn} from '@vueuse/core' import { useStyleTag, useIntervalFn} from '@vueuse/core'
import { color } from '~/composables/color'; import { color } from '~/composables/color';
import { generateTrackCreditStringFromQueue } from '~/utils/utils' import { generateTrackCreditStringFromQueue } from '~/utils/utils'
@ -80,7 +80,18 @@ store.dispatch('auth/fetchUser')
<template> <template>
<div class="funkwhale responsive"> <div class="funkwhale responsive">
<Sidebar /> <Sidebar />
<RouterView v-bind="color({}, ['default', 'solid'])()" /> <RouterView v-bind="color({}, ['default', 'solid'])()" v-slot="{ Component }">
<Transition v-if="Component" name="main" mode="out-in">
<KeepAlive :max="10">
<Suspense>
<component :is="Component" />
<template #fallback>
FALLBACK
</template>
</Suspense>
</KeepAlive>
</Transition>
</RouterView>
<transition name="queue"> <transition name="queue">
<Queue v-show="store.state.ui.queueFocused" /> <Queue v-show="store.state.ui.queueFocused" />
</transition> </transition>

View File

@ -88,10 +88,8 @@ const library = ref<Library>()
watch(privacyLevel, (newValue) => watch(privacyLevel, (newValue) =>
get({ get({
query: {
privacy_level: newValue, privacy_level: newValue,
scope: 'me' scope: 'me'
}
}) })
.then((data) => .then((data) =>
library.value = data?.results.find(({name}) => name === privacyLevel.value) library.value = data?.results.find(({name}) => name === privacyLevel.value)
@ -100,20 +98,20 @@ watch(privacyLevel, (newValue) =>
) )
// Old implementation: // Old implementation:
/*
watch(privacyLevel, async(newValue) => { try {
const response = await axios.get<paths['/api/v2/libraries/']['get']['responses']['200']['content']['application/json']>('libraries/', {
params: {
privacy_level: privacyLevel.value,
scope: 'me'
}
})
library.value = response.data.results.find(({name})=>name===privacyLevel.value) // watch(privacyLevel, async(newValue) => { try {
} catch (error) { // const response = await axios.get<paths['/api/v2/libraries/']['get']['responses']['200']['content']['application/json']>('libraries/', {
useErrorHandler(error as Error) // params: {
}}, { immediate: true }) // privacy_level: privacyLevel.value,
*/ // scope: 'me'
// }
// })
// library.value = response.data.results.find(({name})=>name===privacyLevel.value)
// } catch (error) {
// useErrorHandler(error as Error)
// }}, { immediate: true })
// //
// File counts // File counts

View File

@ -28,6 +28,7 @@ const store: Module<State, RootState> = {
state: { state: {
subscriptions: [], subscriptions: [],
count: 0, count: 0,
// TODO: Remove this. It has been moved to store/ui
showUploadModal: false, showUploadModal: false,
latestPublication: null, latestPublication: null,
uploadModalConfig: { uploadModalConfig: {

View File

@ -32,6 +32,8 @@ interface Message {
type NotificationsKey = 'inbox' | 'pendingReviewEdits' | 'pendingReviewReports' | 'pendingReviewRequests' type NotificationsKey = 'inbox' | 'pendingReviewEdits' | 'pendingReviewReports' | 'pendingReviewRequests'
type IsOpen = 'true' | 'undefined'
export interface State { export interface State {
currentLanguage: 'en_US' | keyof typeof SUPPORTED_LOCALES currentLanguage: 'en_US' | keyof typeof SUPPORTED_LOCALES
selectedLanguage: boolean selectedLanguage: boolean
@ -152,7 +154,7 @@ const store: Module<State, RootState> = {
return 'large' return 'large'
} }
}, },
modalShown: (state, key) => modalIsOpen: (state, key) =>
state.modalsOpen.has(key) state.modalsOpen.has(key)
}, },
mutations: { mutations: {
@ -197,20 +199,15 @@ const store: Module<State, RootState> = {
addModal (state, key) { addModal (state, key) {
state.modalsOpen.add(key) state.modalsOpen.add(key)
console.log("Added", key, "->", state.modalsOpen)
}, },
removeModal (state, key) { removeModal (state, key) {
state.modalsOpen.delete(key) state.modalsOpen.delete(key)
console.log("Removed", key, "->", state.modalsOpen)
}, },
toggleModal (state, key) { toggleModal (state, key) {
state.modalsOpen.has(key) ? state.modalsOpen.delete(key) : state.modalsOpen.add(key) state.modalsOpen.has(key) ? state.modalsOpen.delete(key) : state.modalsOpen.add(key)
console.log("Toggled", key, "->", state.modalsOpen)
}, },
setModal (state, [key, isOpen]:[string, boolean]) { setModal (state, [key, isOpen]:[string, IsOpen]) {
console.log("Set", key, "was:", state.modalsOpen.has(key) )
isOpen ? state.modalsOpen.add(key) : state.modalsOpen.delete(key) isOpen ? state.modalsOpen.add(key) : state.modalsOpen.delete(key)
console.log("Set", key, isOpen, "->", state.modalsOpen)
}, },
notifications (state, { type, count }: { type: NotificationsKey, count: number }) { notifications (state, { type, count }: { type: NotificationsKey, count: number }) {

View File

@ -68,6 +68,7 @@ export type LibraryFollow = components["schemas"]["LibraryFollow"]
export type Cover = components["schemas"]["CoverField"] export type Cover = components["schemas"]["CoverField"]
export type RateLimitStatus = components["schemas"]["RateLimit"] export type RateLimitStatus = components["schemas"]["RateLimit"]
export type PaginatedAlbumList = components["schemas"]["PaginatedAlbumList"] export type PaginatedAlbumList = components["schemas"]["PaginatedAlbumList"]
export type SimpleArtist = components["schemas"]["SimpleArtist"]
export type Artist = components['schemas']['SimpleArtist'] export type Artist = components['schemas']['SimpleArtist']

View File

@ -1,5 +1,5 @@
import { type paths } from '~/generated/types.ts' import type { paths } from '~/generated/types.ts'
import { type Simplify } from 'type-fest' import type { Simplify } from 'type-fest'
import axios from 'axios' import axios from 'axios'
import useErrorHandler from '~/composables/useErrorHandler' import useErrorHandler from '~/composables/useErrorHandler'
@ -16,7 +16,9 @@ type Get<TPath extends Path> = paths[`${Prefix}${TPath}/`]['get']
type Post<TPath extends Path> = paths[`${Prefix}${TPath}/`]['post'] type Post<TPath extends Path> = paths[`${Prefix}${TPath}/`]['post']
type GetRequestParameters<TPath extends Path> = type GetRequestParameters<TPath extends Path> =
Get<TPath> extends { parameters: any } Get<TPath> extends { parameters: { query? : any } }
? Get<TPath>['parameters']['query']
: Get<TPath> extends { parameters: any }
? Get<TPath>['parameters'] ? Get<TPath>['parameters']
: never : never
@ -57,7 +59,7 @@ export const useClient = <TPath extends Path>( path: TPath ) => ({
get: async (parameters: GetRequestParameters<TPath>) => get: async (parameters: GetRequestParameters<TPath>) =>
await axios.get<OK<TPath>>(`${prefix}${path}/`, { await axios.get<OK<TPath>>(`${prefix}${path}/`, {
params: parameters.query || parameters params: parameters
}) })
.then(({ data }) => { return data }) .then(({ data }) => { return data })
.catch (useErrorHandler), .catch (useErrorHandler),