SHA256
Ошибки действий: причина понятным текстом, неотправленное не висит «часиками»
- Чат, ошибка отправки: раньше «часики» оставались в ленте навсегда, а ниже появлялся пузырь «Ошибка отправки: Failed to fetch» от имени пользователя. Теперь временное сообщение убирается, текст возвращается в поле ввода, тост называет причину и предлагает «Повторить». Для уже загруженных файлов «Повторить» отправляет только сообщение с ключами, без новой загрузки. Неудачная пересылка тоже не оставляет «часиков» в целевом чате. - Ошибка начала звонка – тостом с причиной («Нет доступа к микрофону или камере…»), а не пузырём «[Звонок] Ошибка запуска: NotAllowedError…» в переписке; то же для записи голосового. - Общий actionErrorText(): «Не удалось удалить чат. Нет связи с сервером…» вместо «Не удалось удалить чат: unknown» или английского текста исключения. Технический текст – в журнале, на экране – только с инструментами разработчика. Переведены тосты и строки статуса чата, сеансов устройств, профилей, редактирования профиля, кошелька, серверов доступа, «Моего блокчейна» (≈45 мест). Сетевые ошибки браузера распознаются отдельно. «Сервер недоступен. Проверьте, что backend запущен…» → «Нет связи с сервером…». - Системные окна confirm() в рабочих экранах (закрыть сеансы, завершить сеанс, добавить связь, убрать аватар канала, переключить профиль по push, очистить журнал загрузок) – общим диалогом приложения с понятным заголовком. - Документ DM: поведение при ошибке отправки.
This commit is contained in:
@@ -7,9 +7,7 @@ import { createOverflowDots } from '../components/overflow-dots.js';
|
||||
import { directMessages } from '../mock-data.js';
|
||||
import {
|
||||
addAppLogEntry,
|
||||
addChatMessage,
|
||||
addSignedMessageToChat,
|
||||
addSystemChatMessage,
|
||||
addOutgoingPendingMessage,
|
||||
deleteConversationMessagesBefore,
|
||||
getChatMessages,
|
||||
@@ -17,6 +15,7 @@ import {
|
||||
markOutgoingSent,
|
||||
markReadReceiptSentByBaseKey,
|
||||
normalizeDmChatId,
|
||||
removeOutgoingPending,
|
||||
authService,
|
||||
getRememberedDmPeer,
|
||||
rememberDmPeer,
|
||||
@@ -53,6 +52,7 @@ import {
|
||||
} from '../services/dm-history.js';
|
||||
import { DM_CHAT_PREFS_EVENT, isDmChatMuted, isDmChatPinned, setDmChatPinned } from '../services/dm-chat-prefs.js';
|
||||
import { createDmMuteMenuItem } from '../components/dm-mute-menu.js';
|
||||
import { actionErrorText, mediaAccessErrorText } from '../services/ui-error-texts.js';
|
||||
import { loadProfileSnapshot } from '../services/user-profile-params.js';
|
||||
import { makeProfileLinksRoute, makeProfileRoute } from '../services/shine-routes.js';
|
||||
import { openHistoryLayer } from '../router.js';
|
||||
@@ -613,7 +613,7 @@ async function openForwardMessageDialog({ message, sourceChatId = '', onConfirm
|
||||
confirm.disabled = false;
|
||||
back.disabled = false;
|
||||
confirm.textContent = 'Переслать';
|
||||
showToast(error?.message || 'Не удалось переслать сообщение', { kind: 'error', timeoutMs: 2400 });
|
||||
showToast(actionErrorText('Не удалось переслать сообщение', error), { kind: 'error' });
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -623,7 +623,7 @@ async function openForwardMessageDialog({ message, sourceChatId = '', onConfirm
|
||||
list.replaceChildren();
|
||||
const fail = document.createElement('div');
|
||||
fail.className = 'meta-muted dm-forward-loading';
|
||||
fail.textContent = `Не удалось загрузить чаты: ${error?.message || 'unknown'}`;
|
||||
fail.textContent = actionErrorText('Не удалось загрузить чаты', error);
|
||||
list.append(fail);
|
||||
}
|
||||
}
|
||||
@@ -1068,7 +1068,7 @@ function createDmVoiceAttachmentCard(attachment) {
|
||||
else player.pause();
|
||||
syncProgress();
|
||||
} catch (error) {
|
||||
showToast(error?.message || 'Не удалось открыть голосовое сообщение', { kind: 'error', timeoutMs: 2600 });
|
||||
showToast(actionErrorText('Не удалось открыть голосовое сообщение', error), { kind: 'error' });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1082,7 +1082,7 @@ function createDmVoiceAttachmentCard(attachment) {
|
||||
player.currentTime = player.duration * ratio;
|
||||
syncProgress();
|
||||
} catch (error) {
|
||||
showToast(error?.message || 'Не удалось открыть голосовое сообщение', { kind: 'error', timeoutMs: 2600 });
|
||||
showToast(actionErrorText('Не удалось открыть голосовое сообщение', error), { kind: 'error' });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1429,10 +1429,9 @@ export function render({ navigate, route, chrome }) {
|
||||
await startOutgoingCall(chatId, { mode });
|
||||
renderChatLog({ scrollMode: 'latest', markAsRead: false });
|
||||
} catch (e) {
|
||||
addSystemChatMessage(chatId, `[Звонок] Ошибка запуска: ${e.message || 'unknown'}`, {
|
||||
from: 'out',
|
||||
kind: 'call-tech',
|
||||
});
|
||||
// Подробности запуска уже в журнале звонка; человеку – причина тостом, а не пузырь в переписке.
|
||||
const mediaReason = mediaAccessErrorText(e);
|
||||
showToast(mediaReason ? `Не удалось начать звонок. ${mediaReason}` : actionErrorText('Не удалось начать звонок', e), { kind: 'error' });
|
||||
renderChatLog({ scrollMode: 'latest', markAsRead: false });
|
||||
}
|
||||
};
|
||||
@@ -1544,7 +1543,7 @@ export function render({ navigate, route, chrome }) {
|
||||
try {
|
||||
await addPeerToContacts();
|
||||
} catch (error) {
|
||||
showToast(`Не удалось добавить в контакты: ${error?.message || 'unknown'}`, { kind: 'error', timeoutMs: 1600 });
|
||||
showToast(actionErrorText('Не удалось добавить в контакты', error), { kind: 'error' });
|
||||
}
|
||||
},
|
||||
}
|
||||
@@ -1563,7 +1562,7 @@ export function render({ navigate, route, chrome }) {
|
||||
await clearConversationHistory();
|
||||
showToast('История чата очищена', { timeoutMs: 1200 });
|
||||
} catch (error) {
|
||||
showToast(`Не удалось очистить историю: ${error?.message || 'unknown'}`, { kind: 'error', timeoutMs: 1600 });
|
||||
showToast(actionErrorText('Не удалось очистить историю', error), { kind: 'error' });
|
||||
}
|
||||
},
|
||||
}),
|
||||
@@ -1602,7 +1601,7 @@ export function render({ navigate, route, chrome }) {
|
||||
showToast('Чат удалён', { timeoutMs: 1200 });
|
||||
navigate('messages-list');
|
||||
} catch (error) {
|
||||
showToast(`Не удалось удалить чат: ${error?.message || 'unknown'}`, { kind: 'error', timeoutMs: 1600 });
|
||||
showToast(actionErrorText('Не удалось удалить чат', error), { kind: 'error' });
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -2122,7 +2121,7 @@ export function render({ navigate, route, chrome }) {
|
||||
if (event.data?.size > 0) voiceChunks.push(event.data);
|
||||
});
|
||||
recorder.addEventListener('error', (event) => {
|
||||
showToast(event?.error?.message || 'Ошибка записи микрофона', { kind: 'error', timeoutMs: 2200 });
|
||||
showToast(actionErrorText('Запись с микрофона прервалась', event?.error), { kind: 'error' });
|
||||
});
|
||||
recorder.addEventListener('stop', async () => {
|
||||
const shouldSend = recorder.__shineShouldSend !== false;
|
||||
@@ -2157,9 +2156,9 @@ export function render({ navigate, route, chrome }) {
|
||||
},
|
||||
});
|
||||
await sendFileAttachmentMessage([attachment]);
|
||||
showToast('Голосовое сообщение отправлено.', { timeoutMs: 1200 });
|
||||
showToast('Голосовое отправлено', { timeoutMs: 1200 });
|
||||
} catch (error) {
|
||||
showToast(error?.message || 'Не удалось отправить голосовое сообщение', { kind: 'error', timeoutMs: 2800 });
|
||||
showToast(actionErrorText('Голосовое не отправлено', error), { kind: 'error' });
|
||||
} finally {
|
||||
voiceBusy = false;
|
||||
updateSendButtonMode();
|
||||
@@ -2180,11 +2179,8 @@ export function render({ navigate, route, chrome }) {
|
||||
clearVoiceTimer();
|
||||
stopVoiceStreamTracks();
|
||||
updateSendButtonMode();
|
||||
const denied = error?.name === 'NotAllowedError' || error?.name === 'SecurityError';
|
||||
showToast(
|
||||
denied ? 'Нужно разрешить Сиянию доступ к микрофону.' : (error?.message || 'Не удалось начать запись'),
|
||||
{ kind: 'error', timeoutMs: 2600 },
|
||||
);
|
||||
const mediaReason = mediaAccessErrorText(error);
|
||||
showToast(mediaReason ? `Не удалось начать запись. ${mediaReason}` : actionErrorText('Не удалось начать запись', error), { kind: 'error' });
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2463,6 +2459,8 @@ export function render({ navigate, route, chrome }) {
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
// Текст возвращается в поле ввода, «часики» из ленты убираются; «Повторить» отправляет его снова.
|
||||
removeOutgoingPending(tempId);
|
||||
if (input) {
|
||||
input.value = text;
|
||||
autoResizeComposer(input);
|
||||
@@ -2470,7 +2468,10 @@ export function render({ navigate, route, chrome }) {
|
||||
updateSendButtonMode();
|
||||
focusInputToEnd();
|
||||
}
|
||||
addChatMessage(chatId, `${activeEdit ? 'Ошибка изменения' : 'Ошибка отправки'}: ${e.message || 'unknown'}`);
|
||||
showToast(actionErrorText(activeEdit ? 'Изменение не сохранено' : 'Сообщение не отправлено', e), {
|
||||
kind: 'error',
|
||||
action: { label: 'Повторить', onClick: () => { if (!disposed) form.requestSubmit(); } },
|
||||
});
|
||||
addAppLogEntry({
|
||||
level: 'warn',
|
||||
source: 'outgoing-dm',
|
||||
@@ -2546,7 +2547,7 @@ export function render({ navigate, route, chrome }) {
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
addChatMessage(chatId, `Ошибка отправки вложения: ${error?.message || 'unknown'}`);
|
||||
removeOutgoingPending(tempId);
|
||||
addAppLogEntry({
|
||||
level: 'warn',
|
||||
source: onlyVoice ? 'outgoing-dm-voice' : 'outgoing-dm-file',
|
||||
@@ -2562,6 +2563,25 @@ export function render({ navigate, route, chrome }) {
|
||||
}
|
||||
};
|
||||
|
||||
// Файлы уже лежат на сервере – повторить можно одно сообщение с ключами, без новой загрузки.
|
||||
const offerAttachmentsRetry = (attachments, error) => {
|
||||
showToast(actionErrorText(attachments.length === 1 ? 'Файл не отправлен' : 'Файлы не отправлены', error), {
|
||||
kind: 'error',
|
||||
action: {
|
||||
label: 'Повторить',
|
||||
onClick: async () => {
|
||||
if (disposed) return;
|
||||
try {
|
||||
await sendFileAttachmentMessage(attachments);
|
||||
if (!disposed) showToast(attachments.length === 1 ? 'Файл отправлен' : `Отправлено файлов: ${attachments.length}`, { timeoutMs: 1300 });
|
||||
} catch (again) {
|
||||
if (!disposed) offerAttachmentsRetry(attachments, again);
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
const handleSelectedFiles = async (fileList) => {
|
||||
if (!fileTransferEnabled) {
|
||||
showToast('Передача файлов отключена в дополнительных настройках.', { kind: 'error', timeoutMs: 1800 });
|
||||
@@ -2585,6 +2605,7 @@ export function render({ navigate, route, chrome }) {
|
||||
if (fileToggle) fileToggle.setAttribute('aria-label', 'Шифрование и загрузка файлов');
|
||||
|
||||
const attachments = [];
|
||||
let uploaded = false;
|
||||
try {
|
||||
for (let index = 0; index < allFiles.length; index += 1) {
|
||||
const file = allFiles[index];
|
||||
@@ -2602,11 +2623,13 @@ export function render({ navigate, route, chrome }) {
|
||||
});
|
||||
attachments.push(attachment);
|
||||
}
|
||||
uploaded = true;
|
||||
await sendFileAttachmentMessage(attachments);
|
||||
setFileActionVisible(false);
|
||||
showToast(attachments.length === 1 ? 'Файл отправлен.' : `Отправлено файлов: ${attachments.length}.`, { timeoutMs: 1300 });
|
||||
showToast(attachments.length === 1 ? 'Файл отправлен' : `Отправлено файлов: ${attachments.length}`, { timeoutMs: 1300 });
|
||||
} catch (error) {
|
||||
showToast(error?.message || 'Не удалось отправить файлы', { kind: 'error', timeoutMs: 2800 });
|
||||
if (uploaded) offerAttachmentsRetry(attachments, error);
|
||||
else showToast(actionErrorText(allFiles.length === 1 ? 'Не удалось загрузить файл' : 'Не удалось загрузить файлы', error), { kind: 'error' });
|
||||
} finally {
|
||||
attachButtons.forEach((button) => {
|
||||
button.disabled = false;
|
||||
@@ -2660,8 +2683,8 @@ export function render({ navigate, route, chrome }) {
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
// Оставляем pending-сообщение в локальной истории так же, как обычная отправка,
|
||||
// а пользователю возвращаем ошибку для повторной попытки.
|
||||
// Неотправленное не остаётся в ленте «часиками»; ошибку с причиной покажет окно пересылки.
|
||||
removeOutgoingPending(tempId);
|
||||
if (targetChatId === chatId) renderChatLog({ scrollMode: 'latest', markAsRead: false });
|
||||
throw error;
|
||||
}
|
||||
@@ -2705,7 +2728,7 @@ export function render({ navigate, route, chrome }) {
|
||||
try {
|
||||
await sendDeleteRevision(msg);
|
||||
} catch (error) {
|
||||
showToast(`Не удалось удалить сообщение: ${error?.message || 'unknown'}`, { kind: 'error', timeoutMs: 1500 });
|
||||
showToast(actionErrorText('Не удалось удалить сообщение', error), { kind: 'error' });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user