SHA256
Полностью поддерживает английский язык
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { t } from '../i18n/index.js';
|
||||
import { addAppLogEntry, addSignedMessageToChat, authService, authorizeSession, state } from '../state.js';
|
||||
import { buildDmCallTechBlock } from './dm-tech-blocks.js';
|
||||
|
||||
@@ -150,23 +151,23 @@ function parseInviteData(data = '') {
|
||||
|
||||
function getCallTitleText(mode) {
|
||||
if (normalizeCallMode(mode) === CALL_MODE_INSTANT_VIDEO) {
|
||||
return 'Видеозвонок';
|
||||
return t('remaining.call.video_call');
|
||||
}
|
||||
if (normalizeCallMode(mode) === CALL_MODE_VIDEO) {
|
||||
return 'Видеозвонок';
|
||||
return t('remaining.call.video_call');
|
||||
}
|
||||
return 'Звонок';
|
||||
return t('remaining.call.call');
|
||||
}
|
||||
|
||||
function getIncomingCallStatusText(peerLogin, mode) {
|
||||
const name = String(peerLogin || '').trim();
|
||||
if (normalizeCallMode(mode) === CALL_MODE_INSTANT_VIDEO) {
|
||||
return `Входящий видеозвонок от ${name}`;
|
||||
return t('remaining.call.incoming_video', { name });
|
||||
}
|
||||
if (isVideoCallMode(mode)) {
|
||||
return `Входящий видеозвонок от ${name}`;
|
||||
return t('remaining.call.incoming_video', { name });
|
||||
}
|
||||
return `Вам звонит ${name}`;
|
||||
return t('remaining.call.incoming_voice', { name });
|
||||
}
|
||||
|
||||
function parseConnectStartWinnerSessionId(data = '') {
|
||||
@@ -331,9 +332,9 @@ function formatDuration(ms) {
|
||||
const totalMin = Math.floor(totalSec / 60);
|
||||
const min = totalMin % 60;
|
||||
const hours = Math.floor(totalMin / 60);
|
||||
if (hours > 0) return `${hours}ч ${min}м ${sec}с`;
|
||||
if (min > 0) return `${min}м ${sec}с`;
|
||||
return `${sec}с`;
|
||||
if (hours > 0) return `${hours}${t('remaining.call.unit_h')} ${min}${t('remaining.call.unit_m')} ${sec}${t('remaining.call.unit_s')}`;
|
||||
if (min > 0) return `${min}${t('remaining.call.unit_m')} ${sec}${t('remaining.call.unit_s')}`;
|
||||
return `${sec}${t('remaining.call.unit_s')}`;
|
||||
}
|
||||
|
||||
function isInviteUndelivered(call) {
|
||||
@@ -775,7 +776,7 @@ function setStatus(call, statusText, phase = '') {
|
||||
function buildActiveStatusText(call) {
|
||||
const route = String(call?.connectionRouteLabel || '').trim();
|
||||
const videoSlotMarker = call?.videoSlotReady ? ' +' : '';
|
||||
return route ? `Разговор идёт (${route}${videoSlotMarker})` : 'Разговор идёт';
|
||||
return route ? t('remaining.call.active_route', { route, videoSlotMarker }) : t('remaining.call.call_in_progress');
|
||||
}
|
||||
|
||||
function refreshVideoSlotReady(call) {
|
||||
@@ -1205,8 +1206,8 @@ async function detectConnectionRoute(call) {
|
||||
|
||||
if (localType === 'relay' || remoteType === 'relay') {
|
||||
const label = turnCandidateAddress
|
||||
? `через TURN (${turnCandidateAddress})`
|
||||
: (relayProto ? `через TURN (${relayProto})` : 'через TURN');
|
||||
? t('remaining.call.route_turn_candidate', { address: turnCandidateAddress })
|
||||
: (relayProto ? t('remaining.call.via_turn_proto', { protocol: relayProto }) : t('remaining.call.via_turn'));
|
||||
return { label, details, localIp, remoteIp, turnCandidateAddress };
|
||||
}
|
||||
if (localType || remoteType) {
|
||||
@@ -1216,7 +1217,7 @@ async function detectConnectionRoute(call) {
|
||||
|| (localIp.startsWith('172.16.') && remoteIp.startsWith('172.16.'))
|
||||
);
|
||||
return {
|
||||
label: sameLan ? 'напрямую в локальной сети' : 'напрямую через интернет',
|
||||
label: sameLan ? t('remaining.call.directly_on_local_network') : t('remaining.call.directly_over_the_internet'),
|
||||
details,
|
||||
localIp,
|
||||
remoteIp,
|
||||
@@ -1262,7 +1263,7 @@ function startReconnectFlow(call, reason = 'disconnected') {
|
||||
call.reconnectInProgress = true;
|
||||
call.reconnectAttempts = 0;
|
||||
recordCallTimeline(call, 'reconnect_start', `reason=${reason}`);
|
||||
setStatus(call, 'Связь прервалась. Переподключаем…', 'reconnecting');
|
||||
setStatus(call, t('remaining.call.connection_lost_reconnecting'), 'reconnecting');
|
||||
void emitDebug(call, 'warn', 'peer_connection_reconnect_start', `reason=${reason}`);
|
||||
|
||||
const maxAttempts = 6;
|
||||
@@ -1397,9 +1398,9 @@ async function finalizeCall(call, {
|
||||
}
|
||||
|
||||
call.phase = 'ended';
|
||||
call.statusText = 'Звонок завершён';
|
||||
call.statusText = t('remaining.call.call_ended');
|
||||
if (String(localReasonCode || '') === 'busy') {
|
||||
call.statusText = 'Пользователь занят';
|
||||
call.statusText = t('remaining.call.user_is_busy');
|
||||
}
|
||||
recordCallTimeline(call, 'finalize_end', `reason=${localReasonCode || ''}; status=${call.statusText || ''}`);
|
||||
notifyCallState();
|
||||
@@ -1770,7 +1771,7 @@ async function ensurePeerConnection(call) {
|
||||
ensureReservedVideoTransceiver(call);
|
||||
}
|
||||
} catch (e) {
|
||||
setStatus(call, `Нет доступа к микрофону: ${e?.message || 'unknown'}`, 'failed');
|
||||
setStatus(call, t('remaining.call.microphone_error_full', { error: e?.message || 'unknown' }), 'failed');
|
||||
recordCallTimeline(call, 'local_media_failed', toErrorText(e), 'warn');
|
||||
await emitDebug(call, 'warn', 'microphone_access_failed', toErrorText(e));
|
||||
throw e;
|
||||
@@ -1865,7 +1866,7 @@ async function onAccept(call) {
|
||||
recordCallTimeline(call, 'offer_start', `remoteSession=${call.remoteSessionId || ''}`);
|
||||
call.initialOfferInProgress = true;
|
||||
cleanupTimers(call);
|
||||
setStatus(call, 'Соединяем…', 'connecting');
|
||||
setStatus(call, t('remaining.call.connecting'), 'connecting');
|
||||
try {
|
||||
await notifyPeerSessionsAboutConnectStart(call);
|
||||
const pc = await ensurePeerConnection(call);
|
||||
@@ -1892,7 +1893,7 @@ function ensureIncomingNotification(peerLogin, mode = CALL_MODE_AUDIO) {
|
||||
const text = getIncomingCallStatusText(peerLogin, mode);
|
||||
try {
|
||||
if ('Notification' in window && Notification.permission === 'granted') {
|
||||
new Notification('SHiNE: входящий звонок', { body: text });
|
||||
new Notification(t('remaining.call.shine_incoming_call'), { body: text });
|
||||
}
|
||||
} catch {}
|
||||
try {
|
||||
@@ -2545,7 +2546,7 @@ export async function startOutgoingCall(peerLogin, options = {}) {
|
||||
|
||||
const active = getActiveCall();
|
||||
if (active) {
|
||||
throw new Error(`Уже есть активный звонок с ${active.peerLogin || 'другим пользователем'}`);
|
||||
throw new Error(t('remaining.call.active_call_already', { peer: active.peerLogin || t('remaining.call.another_user') }));
|
||||
}
|
||||
|
||||
const callId = makeCallId();
|
||||
@@ -2553,7 +2554,7 @@ export async function startOutgoingCall(peerLogin, options = {}) {
|
||||
const preflightTimeoutMs = resolveCallPreflightTimeoutMs();
|
||||
const preflightOk = await ensureSessionForCall({ timeoutMs: preflightTimeoutMs, force: false });
|
||||
if (!preflightOk) {
|
||||
throw new Error('Сервер временно недоступен');
|
||||
throw new Error(t('remaining.call.server_temporarily_unavailable'));
|
||||
}
|
||||
|
||||
const call = {
|
||||
@@ -2564,7 +2565,7 @@ export async function startOutgoingCall(peerLogin, options = {}) {
|
||||
autoEnableCameraOnConnect: isInstantVideoMode(callMode),
|
||||
direction: 'out',
|
||||
phase: 'searching',
|
||||
statusText: 'Ищем пользователя…',
|
||||
statusText: t('remaining.call.finding_user'),
|
||||
remoteSessionId: '',
|
||||
timers: {},
|
||||
startedAtMs: nowMs(),
|
||||
@@ -2596,7 +2597,7 @@ export async function startOutgoingCall(peerLogin, options = {}) {
|
||||
calls.set(callId, call);
|
||||
activeCallId = callId;
|
||||
recordCallTimeline(call, 'outgoing_created', `peer=${cleanPeer}`);
|
||||
setStatus(call, 'Ищем пользователя…', 'searching');
|
||||
setStatus(call, t('remaining.call.finding_user'), 'searching');
|
||||
|
||||
call.timers.total35s = setTimeout(() => {
|
||||
if (!calls.has(callId)) return;
|
||||
@@ -2614,7 +2615,7 @@ export async function startOutgoingCall(peerLogin, options = {}) {
|
||||
`ws=${Number(call.inviteDelivery?.deliveredWsSessions || 0)}; push=${Number(call.inviteDelivery?.deliveredWebPushSessions || call.inviteDelivery?.deliveredFcmSessions || 0)}`,
|
||||
);
|
||||
if (getInviteDeliveredCount(call) > 0 && call.phase === 'searching') {
|
||||
setStatus(call, 'Вызываем…', 'ringing');
|
||||
setStatus(call, t('remaining.call.calling'), 'ringing');
|
||||
}
|
||||
scheduleOutgoingAckTimeout(call);
|
||||
} catch (error) {
|
||||
@@ -2627,14 +2628,14 @@ export async function startOutgoingCall(peerLogin, options = {}) {
|
||||
try {
|
||||
call.inviteDelivery = await broadcastSignal(call, TYPES.INVITE, buildInviteData({ mode: callMode }));
|
||||
if (getInviteDeliveredCount(call) > 0 && call.phase === 'searching') {
|
||||
setStatus(call, 'Вызываем…', 'ringing');
|
||||
setStatus(call, t('remaining.call.calling'), 'ringing');
|
||||
}
|
||||
scheduleOutgoingAckTimeout(call);
|
||||
return;
|
||||
} catch {}
|
||||
}
|
||||
await finalizeCall(call, { localReasonCode: 'error', debugReason: 'invite_failed:not_authenticated_after_retry' });
|
||||
throw new Error('Сервер временно недоступен');
|
||||
throw new Error(t('remaining.call.server_temporarily_unavailable'));
|
||||
}
|
||||
await finalizeCall(call, { localReasonCode: 'error', debugReason: `invite_failed:${toErrorText(error)}` });
|
||||
throw error;
|
||||
@@ -2680,7 +2681,7 @@ export async function acceptIncomingCall() {
|
||||
call.cameraEnabled = true;
|
||||
}
|
||||
call.phase = 'connecting';
|
||||
setStatus(call, 'Соединяем…', 'connecting');
|
||||
setStatus(call, t('remaining.call.connecting'), 'connecting');
|
||||
cleanupTimers(call);
|
||||
scheduleIncomingConnectTimeout(call);
|
||||
await sendSignal(call, TYPES.ACCEPT, 'accept');
|
||||
@@ -2777,7 +2778,7 @@ export async function handleIncomingCallSignal(evt) {
|
||||
|
||||
if (type === TYPES.RINGING) {
|
||||
if (call.direction === 'out' && call.phase === 'searching') {
|
||||
setStatus(call, 'Вызываем…', 'ringing');
|
||||
setStatus(call, t('remaining.call.calling'), 'ringing');
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -2794,7 +2795,7 @@ export async function handleIncomingCallSignal(evt) {
|
||||
return;
|
||||
}
|
||||
call.phase = 'connecting';
|
||||
setStatus(call, 'Соединяем…', 'connecting');
|
||||
setStatus(call, t('remaining.call.connecting'), 'connecting');
|
||||
await onAccept(call);
|
||||
return;
|
||||
}
|
||||
@@ -2860,7 +2861,7 @@ export async function handleIncomingCallSignal(evt) {
|
||||
await pc.setLocalDescription(answer);
|
||||
await sendSignal(call, TYPES.ANSWER, JSON.stringify(answer));
|
||||
refreshVideoSlotReady(call);
|
||||
setStatus(call, 'Соединяем…', 'connecting');
|
||||
setStatus(call, t('remaining.call.connecting'), 'connecting');
|
||||
notifyCallState();
|
||||
await emitDebug(call, 'info', 'offer_processed', 'answer sent');
|
||||
} catch (error) {
|
||||
@@ -2901,7 +2902,7 @@ export async function handleIncomingCallSignal(evt) {
|
||||
await flushPendingIceCandidates(call);
|
||||
refreshVideoSlotReady(call);
|
||||
recordCallTimeline(call, 'answer_applied', `from=${fromSessionId || '-'}`);
|
||||
setStatus(call, 'Соединяем…', 'connecting');
|
||||
setStatus(call, t('remaining.call.connecting'), 'connecting');
|
||||
notifyCallState();
|
||||
await emitDebug(call, 'info', 'answer_processed', 'remote description set');
|
||||
} catch (error) {
|
||||
@@ -2994,7 +2995,7 @@ export async function handleCallPushAction(action, payload = {}) {
|
||||
const timeoutMs = resolveCallPreflightTimeoutMs();
|
||||
const ok = await ensureSessionForCall({ timeoutMs, force: false });
|
||||
if (!ok) {
|
||||
throw new Error('Не удалось подключиться, вызов завершён');
|
||||
throw new Error(t('remaining.call.could_not_connect_call_ended'));
|
||||
}
|
||||
await handleIncomingCallPush(payload);
|
||||
if (normalized === 'accept') {
|
||||
|
||||
Reference in New Issue
Block a user