Add interstitial endpoints and enhance media and template functionalities: implement MapInterstitialEndpoints in Program.cs, add preview functionality for media assets in MediaEndpoints, and introduce template preview capabilities in TemplateEndpoints. Remove obsolete bumper settings from Channel and related classes to streamline configuration.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { create } from 'zustand'
|
||||
import { HttpError, refreshAccessToken } from '@/shared/api/client'
|
||||
import { queryClient } from '@/shared/api/query-client'
|
||||
import { importInterstitials } from '@/features/admin/interstitials/api'
|
||||
import { addEpisode } from '@/features/admin/shows/api'
|
||||
import { toast } from '@/shared/ui/toast-store'
|
||||
import { listMedia, uploadMedia } from './api'
|
||||
@@ -33,11 +34,13 @@ type UploadStore = {
|
||||
export type EnqueueOptions = {
|
||||
showId?: string
|
||||
resolveShowId?: (file: File) => string | undefined
|
||||
/** Загрузка с экрана «Ролики»: каждый файл после аплоада становится роликом (Show + серия). */
|
||||
interstitial?: boolean
|
||||
}
|
||||
|
||||
// Очередь и флаг живут вне React — загрузка продолжается при любой навигации.
|
||||
let counter = 0
|
||||
type Job = { id: string; file: File; showId?: string }
|
||||
type Job = { id: string; file: File; showId?: string; interstitial?: boolean }
|
||||
const queue: Job[] = []
|
||||
const controllers = new Map<string, AbortController>()
|
||||
const failed = new Map<string, Job>() // упавшие — для ручного повтора
|
||||
@@ -112,6 +115,14 @@ async function pump() {
|
||||
} catch {
|
||||
toast.error(`${job.file.name}: не удалось добавить в шоу`)
|
||||
}
|
||||
} else if (job.interstitial) {
|
||||
// Ролик заводится сразу после аплоада: длительность подтянется, когда ассет обработается.
|
||||
try {
|
||||
await importInterstitials([created.id])
|
||||
void queryClient.invalidateQueries({ queryKey: ['admin', 'interstitials'] })
|
||||
} catch {
|
||||
toast.error(`${job.file.name}: не удалось завести ролик`)
|
||||
}
|
||||
}
|
||||
} else if (isAbort(lastError) || controller.signal.aborted) {
|
||||
// Отмена — тихо: элемент уже убран из списка.
|
||||
@@ -157,7 +168,7 @@ export const useUploadStore = create<UploadStore>((set) => ({
|
||||
const newItems: UploadItem[] = toAdd.map((file) => {
|
||||
const id = `u${++counter}`
|
||||
const showId = options?.resolveShowId?.(file) ?? options?.showId
|
||||
queue.push({ id, file, showId })
|
||||
queue.push({ id, file, showId, interstitial: options?.interstitial })
|
||||
return { id, name: file.name, percent: 0, status: 'queued' }
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user