fix: token will be fetched everytime to make sure it is the latest
This commit is contained in:
parent
1c7998c554
commit
7cff930861
@ -92,8 +92,30 @@ const context = {
|
|||||||
// native_run_api_endpoint: "http://localhost:3011/api/run",
|
// native_run_api_endpoint: "http://localhost:3011/api/run",
|
||||||
// };
|
// };
|
||||||
|
|
||||||
function getSelectedWorkflowInfo() {
|
async function getSelectedWorkflowInfo() {
|
||||||
return context.selectedWorkflowInfo;
|
const workflow_info_promise = new Promise((resolve) => {
|
||||||
|
try {
|
||||||
|
const handleMessage = (event) => {
|
||||||
|
try {
|
||||||
|
const message = JSON.parse(event.data);
|
||||||
|
if (message.type === "workflow_info") {
|
||||||
|
resolve(message.data);
|
||||||
|
window.removeEventListener("message", handleMessage);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
resolve(undefined);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
window.addEventListener("message", handleMessage);
|
||||||
|
sendEventToCD("workflow_info");
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
resolve(undefined);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return workflow_info_promise;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSelectedWorkflowInfo(info) {
|
function setSelectedWorkflowInfo(info) {
|
||||||
@ -105,6 +127,8 @@ function setSelectedWorkflowInfo(info) {
|
|||||||
const ext = {
|
const ext = {
|
||||||
name: "BennyKok.ComfyUIDeploy",
|
name: "BennyKok.ComfyUIDeploy",
|
||||||
|
|
||||||
|
native_mode: false,
|
||||||
|
|
||||||
init(app) {
|
init(app) {
|
||||||
addButton();
|
addButton();
|
||||||
|
|
||||||
@ -114,6 +138,7 @@ const ext = {
|
|||||||
const org_display = queryParams.get("org_display");
|
const org_display = queryParams.get("org_display");
|
||||||
const origin = queryParams.get("origin");
|
const origin = queryParams.get("origin");
|
||||||
const workspace_mode = queryParams.get("workspace_mode");
|
const workspace_mode = queryParams.get("workspace_mode");
|
||||||
|
this.native_mode = queryParams.get("native_mode") === "true";
|
||||||
|
|
||||||
if (workspace_mode) {
|
if (workspace_mode) {
|
||||||
document.querySelector(".comfy-menu").style.display = "none";
|
document.querySelector(".comfy-menu").style.display = "none";
|
||||||
@ -319,7 +344,10 @@ const ext = {
|
|||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warning("Error setting validation to false, is fine to ignore this", error);
|
console.warning(
|
||||||
|
"Error setting validation to false, is fine to ignore this",
|
||||||
|
error,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
console.log("loadGraphData");
|
console.log("loadGraphData");
|
||||||
app.loadGraphData(comfyUIWorkflow);
|
app.loadGraphData(comfyUIWorkflow);
|
||||||
@ -1527,10 +1555,12 @@ async function loadWorkflowApi(versionId) {
|
|||||||
|
|
||||||
const orginal_fetch_api = api.fetchApi;
|
const orginal_fetch_api = api.fetchApi;
|
||||||
api.fetchApi = async (route, options) => {
|
api.fetchApi = async (route, options) => {
|
||||||
console.log("Fetch API called with args:", route, options);
|
console.log("Fetch API called with args:", route, options, ext.native_mode);
|
||||||
|
|
||||||
const info = getSelectedWorkflowInfo();
|
if (route.startsWith("/prompt") && ext.native_mode) {
|
||||||
if (info && route.startsWith("/prompt")) {
|
const info = await getSelectedWorkflowInfo();
|
||||||
|
console.log("info", info);
|
||||||
|
if (info) {
|
||||||
const body = JSON.parse(options.body);
|
const body = JSON.parse(options.body);
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
@ -1553,6 +1583,7 @@ api.fetchApi = async (route, options) => {
|
|||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return await orginal_fetch_api.call(api, route, options);
|
return await orginal_fetch_api.call(api, route, options);
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user