Add live request pipeline recheck
This commit is contained in:
@@ -427,6 +427,38 @@ export default function RequestTimelinePage() {
|
||||
const posterUrl = snapshot.artwork?.poster_url
|
||||
const resolvedPoster = posterUrl?.startsWith('http') ? posterUrl : posterUrl ? `${getApiBase()}${posterUrl}` : null
|
||||
|
||||
const recheckRequest = async () => {
|
||||
setBusyAction('recheck_pipeline')
|
||||
setActionError(null)
|
||||
setActionMessage(null)
|
||||
setReleaseOptions([])
|
||||
try {
|
||||
const response = await authFetch(
|
||||
`${getApiBase()}/requests/${snapshot.request_id}/actions/recheck`,
|
||||
{ method: 'POST' }
|
||||
)
|
||||
if (response.status === 401) {
|
||||
clearToken()
|
||||
router.push('/login')
|
||||
return
|
||||
}
|
||||
if (!response.ok) {
|
||||
throw new Error(await readApiError(response, 'The request could not be rechecked.'))
|
||||
}
|
||||
const data = await response.json()
|
||||
if (!isSnapshotPayload(data?.snapshot)) {
|
||||
throw new Error('The request was checked, but Magent did not return a valid pipeline.')
|
||||
}
|
||||
setSnapshot(data.snapshot)
|
||||
setActionMessage(data?.message ?? 'Request status rebuilt from live service data.')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
setActionError(error instanceof Error ? error.message : 'The request could not be rechecked.')
|
||||
} finally {
|
||||
setBusyAction(null)
|
||||
}
|
||||
}
|
||||
|
||||
const runAction = async (action: RequestAction) => {
|
||||
if (action.requires_confirmation && !window.confirm(`Run “${action.label}”?`)) return
|
||||
const actionPaths: Record<string, string> = {
|
||||
@@ -538,15 +570,22 @@ export default function RequestTimelinePage() {
|
||||
<span className="request-overview-label">Next step</span>
|
||||
<strong>{nextStep.title}</strong>
|
||||
<p>{nextStep.description}</p>
|
||||
{recommendedActions.length > 0 && (
|
||||
<div className="request-action-row">
|
||||
{recommendedActions.map((action) => (
|
||||
<button key={action.id} type="button" disabled={Boolean(busyAction)} onClick={() => void runAction(action)}>
|
||||
{busyAction === action.id ? 'Working…' : action.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
<div className="request-action-row">
|
||||
{recommendedActions.map((action) => (
|
||||
<button key={action.id} type="button" disabled={Boolean(busyAction)} onClick={() => void runAction(action)}>
|
||||
{busyAction === action.id ? 'Working…' : action.label}
|
||||
</button>
|
||||
))}
|
||||
<button
|
||||
type="button"
|
||||
className="request-recheck-button"
|
||||
disabled={Boolean(busyAction)}
|
||||
onClick={() => void recheckRequest()}
|
||||
title="Recheck Seerr, the library collector, qBittorrent, and the media server"
|
||||
>
|
||||
{busyAction === 'recheck_pipeline' ? 'Rechecking…' : 'Recheck request'}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{(actionMessage || actionError) && (
|
||||
<div className={`request-action-feedback ${actionError ? 'is-error' : 'is-success'}`} role="status">
|
||||
|
||||
Reference in New Issue
Block a user