mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-05 17:58:55 +00:00
fix null field in sora image gen status; frontend polling disable flag
This commit is contained in:
1 parent
adf9b07744
commit
9c24dbd446
4 files changed
+49
-3
No files matched your search
+3
-3
@@ -173,7 +173,7 @@ pub struct InpaintItem {
|
||||
pub r#type: String,
|
||||
pub preset_id: Option<String>,
|
||||
pub generation_id: Option<String>,
|
||||
pub upload_media_id: String,
|
||||
pub upload_media_id: Option<String>,
|
||||
pub frame_index: i32,
|
||||
pub source_start_frame: i32,
|
||||
}
|
||||
@@ -202,7 +202,7 @@ impl StatusRequest {
|
||||
|
||||
/// Gets the status of image generation tasks from Sora API
|
||||
pub async fn get_image_gen_status(status_request: &StatusRequest, credentials: &SoraCredentialSet) -> Result<VideoGenStatusResponse, SoraError> {
|
||||
|
||||
|
||||
let bearer_header = match credentials.jwt_bearer_token.as_ref() {
|
||||
Some(bearer) => bearer.to_authorization_header_value(),
|
||||
None => {
|
||||
@@ -316,7 +316,7 @@ mod tests {
|
||||
|
||||
let creds = SoraCredentials { bearer_token: bearer, cookie, sentinel: Some(sentinel) };
|
||||
let new_creds = SoraCredentialSet::from_legacy_credentials(&creds)?;
|
||||
|
||||
|
||||
// Get the task status for a specific task
|
||||
// let response = get_image_gen_status(&StatusRequest::new(None, Some("task_01jr9yvpfyetx9r7qvvx38scna".to_string())), &creds).await?;
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
|
||||
// This is used to do things such as disable job polling in the dev console.
|
||||
|
||||
export const SetDevFlag = (flagName: string, value: any) => {
|
||||
if (!!!(window as any)._dev_flags) {
|
||||
(window as any)._dev_flags = {};
|
||||
}
|
||||
(window as any)._dev_flags[flagName] = value;
|
||||
}
|
||||
|
||||
export const GetDevFlag = (flagName: string) => {
|
||||
if (!!(window as any)._dev_flags && flagName in (window as any)._dev_flags) {
|
||||
return (window as any)._dev_flags[flagName];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export const DisableJobPolling = () => {
|
||||
SetDevFlag("disable_job_polling", true);
|
||||
}
|
||||
|
||||
export const EnableJobPolling = () => {
|
||||
SetDevFlag("disable_job_polling", false);
|
||||
}
|
||||
|
||||
export const IsJobPollingDisabled = () : boolean => {
|
||||
return GetDevFlag("disable_job_polling") === true;
|
||||
}
|
||||
|
||||
(window as any).setDevFlag = SetDevFlag;
|
||||
(window as any).getDevFlag = GetDevFlag;
|
||||
|
||||
(window as any).disableJobPolling = DisableJobPolling;
|
||||
(window as any).enableJobPolling = EnableJobPolling;
|
||||
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
import { ToastTypes } from "~/enums";
|
||||
import { addToast, setJobs } from "~/signals";
|
||||
import { JobsApi } from "~/Classes/ApiManager/JobsApi";
|
||||
import { IsJobPollingDisabled } from "~/flags/DevConsoleFlags";
|
||||
|
||||
export async function PollRecentJobs() {
|
||||
const jobsApi = new JobsApi();
|
||||
|
||||
if (IsJobPollingDisabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const response = await jobsApi.ListRecentJobs();
|
||||
if (response.success && response.data) {
|
||||
setJobs(response.data);
|
||||
|
||||
@@ -9,6 +9,7 @@ import { useEffect, useState, useRef, useCallback } from "react";
|
||||
import { JobsApi } from "~/Classes/ApiManager/JobsApi";
|
||||
import { toast } from "@storyteller/ui-toaster";
|
||||
import { ActiveJob } from "~/pages/PageEnigma/models";
|
||||
import { IsJobPollingDisabled } from "~/flags/DevConsoleFlags";
|
||||
// TODO ensure we de-dupe all this extra code.
|
||||
interface CompletedItem {
|
||||
token: string;
|
||||
@@ -85,6 +86,9 @@ export function Activity() {
|
||||
let mounted = true;
|
||||
|
||||
async function fetchJobs() {
|
||||
if (IsJobPollingDisabled()) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const jobsApi = new JobsApi();
|
||||
const response = await jobsApi.ListRecentJobs();
|
||||
|
||||
Reference in new issue
Block a user