mirror of
https://github.com/NoCrypt/migu.git
synced 2026-04-18 15:12:04 +00:00
fix: audio label
This commit is contained in:
parent
ccb3225873
commit
ceb2eb6a06
3 changed files with 11 additions and 17 deletions
|
|
@ -6,6 +6,8 @@ import { alToken } from '@/modules/settings.js'
|
|||
import { toast } from 'svelte-sonner'
|
||||
import { sleep } from './util.js'
|
||||
|
||||
import { cacheDubs } from '@/modules/audiolabel.js'
|
||||
|
||||
export const codes = {
|
||||
400: 'Bad Request',
|
||||
401: 'Unauthorized',
|
||||
|
|
@ -206,6 +208,8 @@ class AnilistClient {
|
|||
return time
|
||||
})
|
||||
|
||||
cacheDubs()
|
||||
|
||||
if (this.userID?.viewer?.data?.Viewer) {
|
||||
this.userLists.value = this.getUserLists({ sort: 'UPDATED_TIME_DESC' })
|
||||
// update userLists every 15 mins
|
||||
|
|
|
|||
|
|
@ -4,18 +4,10 @@ import { codes } from '@/modules/anilist.js'
|
|||
|
||||
export const dubInfo = writable()
|
||||
|
||||
const initialized = writable(false)
|
||||
|
||||
|
||||
export async function cacheDubs() {
|
||||
await initialized.subscribe(async value => {
|
||||
if (!value) {
|
||||
dubInfo.value = await getDubInfo()
|
||||
initialized.set(true)
|
||||
// update dubInfo every hour
|
||||
setInterval(async () => dubInfo.value = await getDubInfo(), 1000 * 60 * 60)
|
||||
}
|
||||
})
|
||||
dubInfo.value = await getDubInfo()
|
||||
// update dubInfo every hour
|
||||
setInterval(async () => dubInfo.value = await getDubInfo(), 1000 * 60 * 60)
|
||||
}
|
||||
|
||||
async function getDubInfo() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<script>
|
||||
import { onMount } from 'svelte'
|
||||
import { settings } from '@/modules/settings.js'
|
||||
import { cacheDubs } from '@/modules/audiolabel.js'
|
||||
import { dubInfo } from '@/modules/audiolabel.js'
|
||||
|
||||
/** @type {import('@/modules/al.d.ts').Media} */
|
||||
|
|
@ -17,18 +16,17 @@
|
|||
/**
|
||||
* @param {number} id
|
||||
*/
|
||||
async function setLabel(id) {
|
||||
const info = await dubInfo
|
||||
function setLabel(id) {
|
||||
const info = dubInfo
|
||||
if (info && info.value) {
|
||||
isDubbed = info.value.dubbed.includes(id)
|
||||
isPartial = info.value.incomplete.includes(id)
|
||||
}
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
await cacheDubs()
|
||||
onMount(() => {
|
||||
if (media != null) {
|
||||
await setLabel(media.idMal)
|
||||
setLabel(media.idMal)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue