fix - don't spam users when model list not defined

This commit is contained in:
Ishaan Jaff 2024-07-06 10:36:14 -07:00
parent 7b31923597
commit 5d0bb0b9ae
2 changed files with 18 additions and 3 deletions

View file

@ -701,6 +701,9 @@ export const claimOnboardingToken = async (
throw error;
}
};
let ModelListerrorShown = false;
let errorTimer: NodeJS.Timeout | null = null;
export const modelInfoCall = async (
accessToken: String,
userID: String,
@ -722,8 +725,21 @@ export const modelInfoCall = async (
});
if (!response.ok) {
const errorData = await response.text();
message.error(errorData, 10);
let errorData = await response.text();
errorData += `error shown=${ModelListerrorShown}`
if (!ModelListerrorShown) {
if (errorData.includes("No model list passed")) {
errorData = "No Models Exist. Click Add Model to get started.";
}
message.info(errorData, 10);
ModelListerrorShown = true;
if (errorTimer) clearTimeout(errorTimer);
errorTimer = setTimeout(() => {
ModelListerrorShown = false;
}, 10000);
}
throw new Error("Network response was not ok");
}