Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

Commit

Permalink
YouTube export: Better job statuses
Browse files Browse the repository at this point in the history
  • Loading branch information
EdNutting committed May 26, 2022
1 parent cb35904 commit 7847cd4
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,27 @@ gql`
}
`;

function formatJobMessage(message?: string | null, pausedUntil?: string | null) {
function formatJobMessage(
jobStatusName: Job_Queues_JobStatus_Enum,
message?: string | null,
pausedUntil?: string | null
) {
if (jobStatusName === Job_Queues_JobStatus_Enum.InProgress) {
return "Upload in progress. You may close this page while you wait.";
}

if (pausedUntil && Date.parse(pausedUntil) > Date.now())
return `Upload temporarily paused as your YouTube account is currently rate limited. Next attempt will be at ${new Date(
return `Upload temporarily paused as your YouTube account is currently rate limited. Next attempt will be at \`${new Date(
pausedUntil
).toLocaleString()}`;
).toLocaleString()}\``;
if (!message) {
return "Processing...";
}

try {
const messageObj = JSON.parse(message);
if (messageObj.errors && messageObj.errors.length) {
return messageObj.errors.map((x: any) => x.reason + ": " + x.message).join("\n\n");
return messageObj.errors.map((x: any) => `\`${x.reason}\`: ${x.message}`).join("\n\n");
}
} catch {
return message;
Expand Down Expand Up @@ -127,13 +135,18 @@ export function UploadedPage(): JSX.Element {
<FAIcon icon="check-circle" iconStyle="s" aria-label="completed" color="green.500" />
</Tooltip>
);
case Job_Queues_JobStatus_Enum.Expired:
case Job_Queues_JobStatus_Enum.Failed:
return (
<Tooltip label="Upload failed">
<Tooltip label="Upload failed - error">
<FAIcon icon="exclamation-circle" iconStyle="s" aria-label="error" color="red.500" />
</Tooltip>
);
case Job_Queues_JobStatus_Enum.Expired:
return (
<Tooltip label="Upload failed - expired">
<FAIcon icon="stopwatch" iconStyle="s" aria-label="failure" color="red.500" />
</Tooltip>
);
case Job_Queues_JobStatus_Enum.InProgress:
case Job_Queues_JobStatus_Enum.New:
if (pausedUntil && pausedUntil.getTime() >= Date.now()) {
Expand Down Expand Up @@ -212,7 +225,7 @@ export function UploadedPage(): JSX.Element {
/>
)
) : (
formatJobMessage(job.message, job.pausedUntil)
formatJobMessage(job.jobStatusName, job.message, job.pausedUntil)
)}
</Markdown>
</Td>
Expand Down

0 comments on commit 7847cd4

Please sign in to comment.