Finalize dev-1.3 upgrades and Seerr updates
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
import Image from 'next/image'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useParams, useRouter } from 'next/navigation'
|
||||
import { authFetch, clearToken, getApiBase, getEventStreamToken, getToken } from '../../lib/auth'
|
||||
|
||||
type TimelineHop = {
|
||||
@@ -140,7 +140,7 @@ const friendlyState = (value: string) => {
|
||||
}
|
||||
|
||||
const friendlyTimelineStatus = (service: string, status: string) => {
|
||||
if (service === 'Jellyseerr') {
|
||||
if (service === 'Seerr') {
|
||||
const map: Record<string, string> = {
|
||||
Pending: 'Waiting for approval',
|
||||
Approved: 'Approved',
|
||||
@@ -195,7 +195,9 @@ const friendlyTimelineStatus = (service: string, status: string) => {
|
||||
return status
|
||||
}
|
||||
|
||||
export default function RequestTimelinePage({ params }: { params: { id: string } }) {
|
||||
export default function RequestTimelinePage() {
|
||||
const params = useParams<{ id: string | string[] }>()
|
||||
const requestId = Array.isArray(params?.id) ? params.id[0] : params?.id
|
||||
const router = useRouter()
|
||||
const [snapshot, setSnapshot] = useState<Snapshot | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
@@ -208,6 +210,9 @@ export default function RequestTimelinePage({ params }: { params: { id: string }
|
||||
const [historyActions, setHistoryActions] = useState<ActionHistory[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
if (!requestId) {
|
||||
return
|
||||
}
|
||||
const load = async () => {
|
||||
try {
|
||||
if (!getToken()) {
|
||||
@@ -216,9 +221,9 @@ export default function RequestTimelinePage({ params }: { params: { id: string }
|
||||
}
|
||||
const baseUrl = getApiBase()
|
||||
const [snapshotResponse, historyResponse, actionsResponse] = await Promise.all([
|
||||
authFetch(`${baseUrl}/requests/${params.id}/snapshot`),
|
||||
authFetch(`${baseUrl}/requests/${params.id}/history?limit=5`),
|
||||
authFetch(`${baseUrl}/requests/${params.id}/actions?limit=5`),
|
||||
authFetch(`${baseUrl}/requests/${requestId}/snapshot`),
|
||||
authFetch(`${baseUrl}/requests/${requestId}/history?limit=5`),
|
||||
authFetch(`${baseUrl}/requests/${requestId}/actions?limit=5`),
|
||||
])
|
||||
|
||||
if (snapshotResponse.status === 401) {
|
||||
@@ -252,10 +257,10 @@ export default function RequestTimelinePage({ params }: { params: { id: string }
|
||||
}
|
||||
|
||||
load()
|
||||
}, [params.id, router])
|
||||
}, [requestId, router])
|
||||
|
||||
useEffect(() => {
|
||||
if (!getToken()) {
|
||||
if (!getToken() || !requestId) {
|
||||
return
|
||||
}
|
||||
const baseUrl = getApiBase()
|
||||
@@ -267,7 +272,7 @@ export default function RequestTimelinePage({ params }: { params: { id: string }
|
||||
const streamToken = await getEventStreamToken()
|
||||
if (closed) return
|
||||
const streamUrl = `${baseUrl}/events/requests/${encodeURIComponent(
|
||||
params.id
|
||||
requestId
|
||||
)}/stream?stream_token=${encodeURIComponent(streamToken)}`
|
||||
source = new EventSource(streamUrl)
|
||||
|
||||
@@ -278,7 +283,7 @@ export default function RequestTimelinePage({ params }: { params: { id: string }
|
||||
if (!payload || typeof payload !== 'object' || payload.type !== 'request_live') {
|
||||
return
|
||||
}
|
||||
if (String(payload.request_id ?? '') !== String(params.id)) {
|
||||
if (String(payload.request_id ?? '') !== String(requestId)) {
|
||||
return
|
||||
}
|
||||
if (payload.snapshot && typeof payload.snapshot === 'object') {
|
||||
@@ -310,7 +315,7 @@ export default function RequestTimelinePage({ params }: { params: { id: string }
|
||||
closed = true
|
||||
source?.close()
|
||||
}
|
||||
}, [params.id])
|
||||
}, [requestId])
|
||||
|
||||
if (loading) {
|
||||
return (
|
||||
@@ -337,7 +342,7 @@ export default function RequestTimelinePage({ params }: { params: { id: string }
|
||||
const arrStageLabel =
|
||||
snapshot.state === 'NEEDS_ADD' ? 'Push to Sonarr/Radarr' : 'Library queue'
|
||||
const pipelineSteps = [
|
||||
{ key: 'Jellyseerr', label: 'Jellyseerr' },
|
||||
{ key: 'Seerr', label: 'Seerr' },
|
||||
{ key: 'Sonarr/Radarr', label: arrStageLabel },
|
||||
{ key: 'Prowlarr', label: 'Search' },
|
||||
{ key: 'qBittorrent', label: 'Download' },
|
||||
|
||||
Reference in New Issue
Block a user