fix(пополнение): подсказки к новым колонкам «Платежей», отказ 402 снова обновляет значок до кнопки пополнения

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
anor
2026-10-28 15:08:14 +10:00
co-authored by Claude Opus 5.5
parent 7af008d156
commit 7990082207
3 changed files with 19 additions and 7 deletions
+10 -3
View File
@@ -1910,7 +1910,12 @@ function fmtWhen(epoch) {
return d.toLocaleDateString('ru-RU', {day: '2-digit', month: '2-digit'}) + ' в ' + fmtTime(epoch);
}
async function loadLimits() {
let limitsLoading = null;
function loadLimits() {
limitsLoading = _loadLimits();
return limitsLoading;
}
async function _loadLimits() {
try {
const r = await authFetch(API + '/api/limits');
if (!r.ok) return;
@@ -2160,7 +2165,7 @@ async function goTopup() {
}
// После отказа «баланс исчерпан»: кнопка пополнения прямо под отказом.
async function offerTopup(msgDiv) {
await loadLimits();
await limitsLoading;
if (!msgDiv || !lastBalance || !lastBalance.topup) return;
const btn = document.createElement('button');
btn.type = 'button';
@@ -2354,7 +2359,9 @@ async function runChat(text, retried, готовыйПоток, внешнийCt
// последним стоит ответ, а чужой вопрос выше трогать нельзя.
const последний = [...document.querySelectorAll('#messages .msg')].pop();
if (последний && последний.classList.contains('msg-user')) последний.remove();
offerTopup(addMsg('error', await reasonOrText(r))); // и значок узнаёт про «исчерпан»
const отказ = addMsg('error', await reasonOrText(r));
loadLimits(); // значок остатка тоже узнаёт про «баланс исчерпан»
offerTopup(отказ);
// Только в пустое поле: набранное за время запроса не затираем. Событие ввода —
// чтобы штатный черновик сохранил вопрос и он пережил перезагрузку.
const поле = document.getElementById('msg-input');