Fix quota error async-ness

df50fece6c47ca85ee15d9f69ab2d082090e403f

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +5 -7Showing whitespace changes
public/scripts/openai.js+5 -7
@@ -1326,7 +1326,7 @@ function tryParseStreamingError(response, decoded) {
13261326 return;
13271327 }
13281328
13291329 void checkQuotaError(data);
13301330 checkModerationError(data);
13311331
13321332 // these do not throw correctly (equiv to Error("[object Object]"))
@@ -1350,18 +1350,16 @@ function tryParseStreamingError(response, decoded) {
13501350/**
13511351 * Checks if the response contains a quota error and displays a popup if it does.
13521352 * @param data
13531353 * @returns {Promise<void>}
13541354 * @throws {object} - response JSON
13551355 */
13561356async function checkQuotaError(data) {
1357- const errorText = await renderTemplateAsync('quotaError');
1358-
13591357 if (!data) {
13601358 return;
13611359 }
13621360
13631361 if (data.quota_error) {
1364- callPopup(errorText, 'text');
1362+ renderTemplateAsync('quotaError').then((html) => Popup.show.text('Quota Error', html));
13651363
13661364 // this does not throw correctly (equiv to Error("[object Object]"))
13671365 // if trying to fix "[object Object]" displayed to users, start here
@@ -2054,7 +2052,7 @@ async function sendOpenAIRequest(type, messages, signal) {
20542052 else {
20552053 const data = await response.json();
20562054
20572055 await checkQuotaError(data);
20582056 checkModerationError(data);
20592057
20602058 if (data.error) {