fix(types): use auto-generated schema for NodeInfo (About pages; store instance init)
This commit is contained in:
parent
2960b939d9
commit
910a6ab157
|
@ -5,9 +5,10 @@ import { get } from 'lodash-es'
|
||||||
import { humanSize } from '~/utils/filters'
|
import { humanSize } from '~/utils/filters'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
|
||||||
|
import type { components } from '~/generated/types.ts'
|
||||||
|
|
||||||
import SignupForm from '~/components/auth/SignupForm.vue'
|
import SignupForm from '~/components/auth/SignupForm.vue'
|
||||||
import LogoText from '~/components/LogoText.vue'
|
import LogoText from '~/components/LogoText.vue'
|
||||||
import type { NodeInfo } from '~/store/instance'
|
|
||||||
import useMarkdown from '~/composables/useMarkdown'
|
import useMarkdown from '~/composables/useMarkdown'
|
||||||
|
|
||||||
import Link from '~/components/ui/Link.vue'
|
import Link from '~/components/ui/Link.vue'
|
||||||
|
@ -36,15 +37,15 @@ const stats = computed(() => {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
const info = nodeinfo.value ?? {} as NodeInfo
|
const info = nodeinfo.value ?? {} as components['schemas']['NodeInfo20']
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
users: get(info, 'usage.users.activeMonth', null),
|
users: info.usage.users.activeMonth || null,
|
||||||
hours: get(info, 'metadata.content.local.hoursOfContent', null),
|
hours: info.metadata.library.music.hours || null,
|
||||||
artists: get(info, 'metadata.content.local.artists.total', null),
|
artists: info.metadata.library.artists.total || null,
|
||||||
albums: get(info, 'metadata.content.local.albums.total', null),
|
albums: info.metadata.library.albums.total || null,
|
||||||
tracks: get(info, 'metadata.content.local.tracks.total', null),
|
tracks: info.metadata.library.tracks.total || null,
|
||||||
listenings: get(info, 'metadata.usage.listenings.total', null)
|
listenings: info.metadata.usage?.listenings.total || null
|
||||||
}
|
}
|
||||||
|
|
||||||
return { users, hours, data }
|
return { users, hours, data }
|
||||||
|
|
|
@ -4,8 +4,9 @@ import { useStore } from '~/store'
|
||||||
import { get } from 'lodash-es'
|
import { get } from 'lodash-es'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
|
|
||||||
|
import type { components } from '~/generated/types.ts'
|
||||||
|
|
||||||
import useMarkdown from '~/composables/useMarkdown'
|
import useMarkdown from '~/composables/useMarkdown'
|
||||||
import type { NodeInfo } from '~/store/instance'
|
|
||||||
import { useI18n } from 'vue-i18n'
|
import { useI18n } from 'vue-i18n'
|
||||||
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
|
@ -40,7 +41,7 @@ const federationEnabled = computed(() => {
|
||||||
const onDesktop = computed(() => window.innerWidth > 800)
|
const onDesktop = computed(() => window.innerWidth > 800)
|
||||||
|
|
||||||
const stats = computed(() => {
|
const stats = computed(() => {
|
||||||
const info = nodeinfo.value ?? {} as NodeInfo
|
const info = nodeinfo.value ?? {} as components['schemas']['NodeInfo20']
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
users: get(info, 'usage.users.activeMonth', null),
|
users: get(info, 'usage.users.activeMonth', null),
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import type { NodeInfo } from '~/store/instance'
|
import type { NodeInfo } from '~/store/instance'
|
||||||
|
import type { schemas } from '~/generated/types'
|
||||||
import type { InitModule } from '~/types'
|
import type { InitModule } from '~/types'
|
||||||
|
|
||||||
import { whenever } from '@vueuse/core'
|
import { whenever } from '@vueuse/core'
|
||||||
|
@ -15,7 +16,7 @@ export const install: InitModule = async ({ store, router }) => {
|
||||||
const fetchNodeInfo = async () => {
|
const fetchNodeInfo = async () => {
|
||||||
try {
|
try {
|
||||||
const [{ data }] = await Promise.all([
|
const [{ data }] = await Promise.all([
|
||||||
axios.get<NodeInfo>('instance/nodeinfo/2.1/'),
|
axios.get<schemas['NodeInfo20']>('instance/nodeinfo/2.1/'),
|
||||||
store.dispatch('instance/fetchSettings')
|
store.dispatch('instance/fetchSettings')
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ export type Usage = components['schemas']['Usage']
|
||||||
export type LibraryScan = components['schemas']['LibraryScan']
|
export type LibraryScan = components['schemas']['LibraryScan']
|
||||||
export type LibraryFollow = components["schemas"]["LibraryFollow"]
|
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"]['scopes'][number]
|
||||||
export type PaginatedAlbumList = components["schemas"]["PaginatedAlbumList"]
|
export type PaginatedAlbumList = components["schemas"]["PaginatedAlbumList"]
|
||||||
export type SimpleArtist = components["schemas"]["SimpleArtist"]
|
export type SimpleArtist = components["schemas"]["SimpleArtist"]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue