Fix hours and nodeinfo

funkwhale-fix_pwa_manifest
wvffle 2022-12-12 23:35:13 +00:00 zatwierdzone przez JuniorJPDJ
rodzic 75e717785a
commit f4c5ebed18
3 zmienionych plików z 16 dodań i 13 usunięć

Wyświetl plik

@ -45,7 +45,7 @@ tasks:
before: cd front
init: |
yarn install
command: yarn dev --host 0.0.0.0 --base /front/
command: yarn dev --host 0.0.0.0 --base ./
- name: Welcome to Funkwhale development!
env:

Wyświetl plik

@ -4,8 +4,6 @@ import { useStore } from '~/store'
import { get } from 'lodash-es'
import { computed } from 'vue'
import axios from 'axios'
import useMarkdown from '~/composables/useMarkdown'
import type { NodeInfo } from '~/store/instance'
import { useI18n } from 'vue-i18n'
@ -13,12 +11,6 @@ import { useI18n } from 'vue-i18n'
const store = useStore()
const nodeinfo = computed(() => store.state.instance.nodeinfo)
const fetchData = async () => {
const response = await axios.get('instance/nodeinfo/2.0/')
store.commit('instance/nodeinfo', response.data)
}
fetchData()
const { t } = useI18n()
const labels = computed(() => ({
title: t('components.AboutPod.title')

Wyświetl plik

@ -1,18 +1,27 @@
import type { NodeInfo } from '~/store/instance'
import type { InitModule } from '~/types'
import { watch } from 'vue'
import { whenever } from '@vueuse/core'
import axios from 'axios'
export const install: InitModule = async ({ store, router }) => {
await store.dispatch('instance/fetchFrontSettings')
watch(() => store.state.instance.instanceUrl, async () => {
const fetchNodeInfo = async () => {
const [{ data }] = await Promise.all([
axios.get('instance/nodeinfo/2.0/'),
axios.get<NodeInfo>('instance/nodeinfo/2.0/'),
store.dispatch('instance/fetchSettings')
])
if (data.metadata.library.music?.hours) {
data.metadata.library.music.hours = Math.floor(data.metadata.library.music.hours)
}
store.commit('instance/nodeinfo', data)
})
}
whenever(() => store.state.instance.instanceUrl, fetchNodeInfo)
const urlParams = new URLSearchParams(window.location.search)
const serverUrl = urlParams.get('_server')
@ -34,4 +43,6 @@ export const install: InitModule = async ({ store, router }) => {
// TODO (wvffle): Check if it is really needed
store.commit('instance/instanceUrl', store.state.instance.instanceUrl)
}
return fetchNodeInfo()
}