Исправить интерфейс видеозвонка

This commit is contained in:
AidarKC
2026-11-30 12:33:29 +03:00
parent 1e52b4dd2a
commit e32d424eda
6 changed files with 73 additions and 88 deletions
+4 -20
View File
@@ -2265,34 +2265,20 @@ async function applyCameraState(call) {
videoTrack.enabled = true;
}
} else {
const blackTrack = ensureBlackVideoTrack(call);
if (hadSlotBefore) {
if (call.localStream && blackTrack) {
const existingVideoTracks = call.localStream.getVideoTracks?.() || [];
existingVideoTracks.forEach((track) => {
if (track.id !== blackTrack.id) {
try { call.localStream.removeTrack(track); } catch {}
}
});
if (!existingVideoTracks.some((track) => track.id === blackTrack.id)) {
call.localStream.addTrack(blackTrack);
}
}
try {
if (videoTransceiver && videoTransceiver.direction !== 'sendrecv') {
videoTransceiver.direction = 'sendrecv';
}
} catch {}
if (videoTransceiver?.sender) {
try { await videoTransceiver.sender.replaceTrack(blackTrack || null); } catch {}
// A black placeholder is still an active video track for the peer and leaves
// its call UI on a black screen. Removing the source makes the remote track
// mute, which restores the regular avatar call stage until video returns.
try { await videoTransceiver.sender.replaceTrack(null); } catch {}
call.videoSender = videoTransceiver.sender;
bindVideoSenderStream(call, videoTransceiver.sender);
await applyVideoSenderEncodingProfile(videoTransceiver.sender, 'placeholder');
}
} else {
if (call.localStream && blackTrack) {
syncLocalStreamVideoTrack(call, blackTrack, { stopRemoved: false });
}
try {
if (videoTransceiver && videoTransceiver.direction !== 'sendrecv') {
videoTransceiver.direction = 'sendrecv';
@@ -2301,8 +2287,6 @@ async function applyCameraState(call) {
if (hadReservedBefore && videoTransceiver?.sender) {
try { await videoTransceiver.sender.replaceTrack(null); } catch {}
call.videoSender = videoTransceiver.sender;
} else if (call.videoTransportMode === VIDEO_TRANSPORT_SLOT && blackTrack) {
await ensureVideoSenderSlot(call, { sourceTrack: blackTrack, profile: 'placeholder' });
}
}
await disableCameraTrack(call);
+8 -5
View File
@@ -166,7 +166,10 @@ function getIconSvg(name) {
return '<svg viewBox="0 0 24 24" aria-hidden="true"><rect x="9" y="3.5" width="6" height="11" rx="3" fill="none" stroke="currentColor" stroke-width="1.8"/><path d="M6 11.5a6 6 0 0 0 7.2 5.88" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><path d="M12 17.5v3" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><path d="M8.5 20.5h7" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/><path d="M5 5l14 14" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round"/></svg>';
}
if (name === 'hangup') {
return '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M7 7l10 10M17 7 7 17" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"/></svg>';
return '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5.1 8.5c3.8-3.1 10-3.1 13.8 0l-2 2.4a1.3 1.3 0 0 1-1.6.3l-1.6-.8a1.3 1.3 0 0 0-1.2 0l-1.6.8a1.3 1.3 0 0 1-1.6-.3z" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round"/></svg>';
}
if (name === 'answer') {
return '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M5.1 8.5c3.8-3.1 10-3.1 13.8 0l-2 2.4a1.3 1.3 0 0 1-1.6.3l-1.6-.8a1.3 1.3 0 0 0-1.2 0l-1.6.8a1.3 1.3 0 0 1-1.6-.3z" fill="none" stroke="currentColor" stroke-width="1.9" stroke-linecap="round" stroke-linejoin="round" transform="rotate(180 12 12)"/></svg>';
}
if (name === 'minimize') {
return '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 6v12M7.5 10.5 12 6l4.5 4.5" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
@@ -455,16 +458,16 @@ function ensureUi() {
acceptBtn = document.createElement('button');
acceptBtn.type = 'button';
acceptBtn.className = 'call-accept-btn';
acceptBtn.textContent = t('remaining.call_ui.answer');
acceptBtn.className = 'call-call-action-btn call-call-action-btn--accept';
setButtonIcon(acceptBtn, 'answer', t('remaining.call_ui.answer'));
acceptBtn.addEventListener('click', async () => {
await acceptIncomingCall();
});
declineBtn = document.createElement('button');
declineBtn.type = 'button';
declineBtn.className = 'destructive-btn call-decline-btn';
declineBtn.textContent = t('remaining.call_ui.decline');
declineBtn.className = 'call-call-action-btn call-call-action-btn--decline';
setButtonIcon(declineBtn, 'hangup', t('remaining.call_ui.decline'));
declineBtn.addEventListener('click', async () => {
await declineIncomingCall();
});
+35 -62
View File
@@ -407,8 +407,7 @@
.call-overlay-controls--incoming[hidden],
.call-overlay-controls--active[hidden],
.call-icon-btn[hidden],
.call-accept-btn[hidden],
.call-decline-btn[hidden],
.call-call-action-btn[hidden],
.call-minimized-bar-actions[hidden] {
display: none !important;
}
@@ -426,81 +425,54 @@
.call-decline-btn {
min-width: 132px;
}
.call-accept-btn {
min-width: 132px;
min-height: 38px;
padding: 9px 12px;
.call-call-action-btn {
width: 64px;
min-width: 64px;
height: 64px;
padding: 0;
border: 0;
border-radius: var(--radius-sm);
background: transparent;
background-image: none;
box-shadow: none;
color: var(--text-primary);
text-shadow: none;
backdrop-filter: none;
-webkit-backdrop-filter: none;
font-weight: 700;
border-radius: 50%;
color: #fff;
box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
cursor: pointer;
transition: transform 90ms ease, box-shadow 90ms ease, background-color 90ms ease, filter 120ms ease;
transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}
.call-call-action-btn--accept {
background: var(--success);
}
.call-call-action-btn--decline {
background: var(--danger);
}
.call-call-action-btn svg {
width: 31px;
height: 31px;
}
@media (hover: hover) {
.call-accept-btn:hover {
color: var(--text-primary);
background: transparent;
border: 0;
box-shadow: none;
transform: translateY(-1px);
filter: brightness(1.12);
.call-call-action-btn:hover {
transform: translateY(-2px) scale(1.03);
filter: brightness(1.08);
}
}
.call-accept-btn:active {
color: var(--text-primary);
background: color-mix(in srgb, var(--surface) 12%, transparent);
border: 0;
box-shadow:
inset 0 3px 8px rgba(0, 0, 0, 0.58),
inset 0 -1px 2px color-mix(in srgb, var(--text-primary) 8%, transparent);
transform: translateY(1px) scale(0.97);
.call-call-action-btn:active {
transform: scale(0.94);
filter: brightness(0.9);
}
.call-accept-btn:disabled {
opacity: 1;
color: var(--text-secondary);
background: transparent;
border: 0;
box-shadow: none;
.call-call-action-btn:disabled {
opacity: 0.55;
cursor: not-allowed;
transform: none;
filter: none;
}
.call-accept-btn:focus-visible {
outline: 2px solid var(--border-control);
.call-call-action-btn:focus-visible {
outline: 2px solid var(--text-primary);
outline-offset: 2px;
}
.call-accept-btn::before,
.call-accept-btn::after {
background: transparent;
background-image: none;
border-color: transparent;
box-shadow: none;
}
@media (max-width: 420px) {
.call-overlay-controls {
gap: 16px;
@@ -516,8 +488,9 @@
width: 22px;
height: 22px;
}
.call-accept-btn,
.call-decline-btn {
min-width: 124px;
.call-call-action-btn {
width: 58px;
min-width: 58px;
height: 58px;
}
}
@@ -0,0 +1,21 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
const read = (relative) => fs.readFileSync(new URL(relative, import.meta.url), 'utf8');
test('входящий звонок использует зелёную и красную кнопки с иконками трубки', () => {
const ui = read('../js/services/call-ui-service.js');
const css = read('../styles/components/call-ui.css');
assert.match(ui, /setButtonIcon\(acceptBtn, 'answer', t\('remaining\.call_ui\.answer'\)\)/);
assert.match(ui, /setButtonIcon\(declineBtn, 'hangup', t\('remaining\.call_ui\.decline'\)\)/);
assert.match(css, /\.call-call-action-btn--accept\s*\{\s*background: var\(--success\)/);
assert.match(css, /\.call-call-action-btn--decline\s*\{\s*background: var\(--danger\)/);
});
test('выключение камеры не передаёт чёрную видеозаглушку собеседнику', () => {
const service = read('../js/services/call-service.js');
const disabledSlot = service.slice(service.indexOf(' } else {\n if (hadSlotBefore)'), service.indexOf(' await disableCameraTrack(call);'));
assert.match(disabledSlot, /videoTransceiver\.sender\.replaceTrack\(null\)/);
assert.doesNotMatch(disabledSlot, /ensureBlackVideoTrack\(call\)/);
});